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,552 among WordPress.org plugins with 400+ active installations, is #243 of 1,144 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)
v5.0 Current Version v5.0
Updated 1 year ago Last Update on 15 Aug, 2025
Refreshed 15 hours ago Last Refreshed on
#243 of 1,144 in Editor & Writing Top 25% by installs No update in over a year
View on WordPress.org
Rank
#9,552
No change
Active Installs
400+
-15.3%
KW Avg Position
73.3
0.4 better
Downloads
49K
+3 today
Support Resolved
0%
No change
Rating
94%
Review 4.7 out of 5
4.7 (3 reviews)

Next Milestone 500

Total Progress 69%
400+ 500+
319
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 31 more installs to reach 500+

Rank Changes

9,540 9,549 9,559 9,568 9,577 10-09-2026 11-09-2026 12-09-2026 13-09-2026 14-09-2026 15-09-2026 16-09-2026 17-09-2026
9,527 9,542 9,558 9,573 9,588 02-09-2026 03-09-2026 04-09-2026 05-09-2026 06-09-2026 07-09-2026 08-09-2026 09-09-2026 10-09-2026 11-09-2026 12-09-2026 13-09-2026 14-09-2026 15-09-2026 16-09-2026 17-09-2026
Current #9,552
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 10-09-2026 11-09-2026 12-09-2026 13-09-2026 14-09-2026 15-09-2026 16-09-2026 17-09-2026
0 10 20 02-09-2026 03-09-2026 04-09-2026 05-09-2026 06-09-2026 07-09-2026 08-09-2026 09-09-2026 10-09-2026 11-09-2026 12-09-2026 13-09-2026 14-09-2026 15-09-2026 16-09-2026 17-09-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 1 month 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.