Preserve Code Formatting
by Scott Reilly 4.7 (3 reviews)

Preserve Code Formatting

Preserve formatting of code for display by preventing its modification by WordPress and other plugins while also retaining whitespace.

Preserve Code Formatting ranks #9,571 among WordPress.org plugins with 400+ active installations, is #241 of 1,182 in the Editor & Writing category, a 4.7/5 rating from 3 reviews, and was last updated Aug 15, 2025. Data from WordPress.org, refreshed twice daily — see methodology.

Tested up to WP 6.8 (Current: 7.1.4)
v5.0 Current Version v5.0
Updated 1 year ago Last Update on 15 Aug, 2025
Refreshed 1 week ago Last Refreshed on
#241 of 1,182 in Editor & Writing Top 25% by installs Downloads -13.8% this week No update in over a year
View on WordPress.org
Rank
#9,571
— No change
Active Installs
400+
-12.5%
KW Avg Position
19
— No change
Downloads
49K
+1 today
Support Resolved
0%
— No change
Rating
94%
Review 4.7 out of 5
4.7 (3 reviews)

Next Milestone 500

Total Progress 67%
400+ 500+
487
Ranks to Climb
-
Growth Needed
8,000,000
Active Installs
Pro

Unlock Exact Install Count

See the precise estimated active installs for this plugin, calculated from real-time ranking data.

  • Exact install estimates within tiers
  • Track install growth over time
  • Milestone progress predictions
Upgrade to Pro
Need 33 more installs to reach 500+

Rank Changes

9,092 9,332 9,571 9,810 10,050 31-10-2026 01-11-2026 02-11-2026 03-11-2026 04-11-2026 05-11-2026 06-11-2026 07-11-2026
9,554 9,564 9,574 9,584 9,594 23-10-2026 24-10-2026 25-10-2026 26-10-2026 27-10-2026 28-10-2026 29-10-2026 30-10-2026 31-10-2026 01-11-2026 02-11-2026 03-11-2026 04-11-2026 05-11-2026 06-11-2026 07-11-2026
Current #9,571
Change
Best #

Upgrade to Pro

Unlock 30-day and 90-day rank history charts with a Pro subscription.

Upgrade Now

Active Installs Growth

Active Installs 0,000,000+
Growth +0.0%
Peak 0,000,000

Downloads Growth

0 10 20 31-10-2026 01-11-2026 02-11-2026 03-11-2026 04-11-2026 05-11-2026 06-11-2026 07-11-2026
0 10 20 23-10-2026 24-10-2026 25-10-2026 26-10-2026 27-10-2026 28-10-2026 29-10-2026 30-10-2026 31-10-2026 01-11-2026 02-11-2026 03-11-2026 04-11-2026 05-11-2026 06-11-2026 07-11-2026
Downloads
Growth
Peak

Upgrade to Pro

Unlock 30-day, 90-day, and yearly download history charts with a Pro subscription.

Upgrade Now

Reviews & Ratings

4.7
3 reviews
Overall 94%
5
2 (67%)
4
1 (33%)
3
0 (0%)
2
0 (0%)
1
0 (0%)

Security History

Source: WPVulnerability

1 known vulnerability on record · 1 in the last 24 months · checked 3 months ago

  1. Preserve Code Formatting [preserve-code-formatting] < 5.0

    CVE-2025-49386 · Fixed in v5.0

TL;DR

AI summary of the plugin's readme

This plugin is for WordPress site owners displaying code snippets in older, text-based (non-block) posts. It solves the problem of WordPress and other plugins mangling code formatting by preventing HTML-encoding, shortcode processing, and other content modifications while retaining whitespace.

  • Prevents HTML-encoding of text
  • Prevents shortcode processing
  • Preserves whitespace
  • Preserves code in comments
  • Custom tag specification support
  • Filters post content and excerpt
  • Filters comment text

Frequently Asked Questions

Common questions about Preserve Code Formatting

Are you using the visual editor? The visual editor has a tendency to screw up some of your intent, especially when you are attempting to include raw code. This plugin does not make any claims about working when you create posts with the visual editor enabled. How to tell if you're using the visual editor: you're using what is now referred to as the Classic Editor (the editing experience in WordPress that pre-dates the block editor since WordPress 5.0). Above the post content field and to the right, there is a tab labeled "Visual" and another labeled "Text". If you're writing code, you want to use "Text" for such posts and not switch back to "Visual".
Yes, shortcodes within code tags (or any tag processed by this plugin) will be output as pure text and not be processed as shortcodes by WordPress.
Yes, in the sense that it doesn't do anything at all. The code and preformatted blocks in the block editor should preserve code formatting without the need for this plugin. In short, the plugin will completely skip processing posts containing blocks. Use the code or preformatted blocks to format and display your code.
Only if you have older posts written in the text editor from before you began using the block editor. If so, then you would still want this plugin to be enabled so that those older posts have their code formatting preserved. This plugin being active will not interfere with posts created with blocks, all of which will be ignored by the plugin.
Asides from its intentional incompatibility with the block editor or classic visual editor, the main known issue with the plugin is its inability to properly recognize (and thus preserve) nested tags that match the tag being preserved. So within, for example, a tag, the first encountered will be treated as its closing tag even if technically that closing tag belongs to a nested 'code' tag, e.g. ``This examplewith nested code tags</code> will be rendered as if that first/inner closing tag belonged to the first/outer 'code' tag. It was a choice between either supporting the above scenario (which seems pretty rare overall) or supporting having multiple adjacent preserved tags in a post (which is much more common). A more robust solution is being pursued.
Yes. The tests are not packaged in the release .zip file or included in plugins.svn.wordpress.org, but can be found in the plugin's GitHub repository. The tests are expecting to be run with PHPUnit 9 and you'll likely experience errors if running them under another version.

Sign In / Register

You need to sign in or register to use this feature.