Has this ever happened to you?
You spend ages carefully formatting a code snippet or custom HTML for a WordPress post. You hit publish and excitedly visit your site to admire your handiwork. But to your horror, it‘s a mess! The quotes are all curly, your line breaks are gone, and weird
tags have appeared out of nowhere.
If that sounds painfully familiar, you‘ve experienced the often frustrating effects of WordPress‘s automatic formatting.
While WordPress‘s built-in formatting can be helpful for cleaning up your content, there are plenty of situations where you need to preserve your formatting exactly how you entered it, without WordPress messing with it.
In this guide, we‘ll dive deep into why and how to disable automatic formatting in WordPress. You‘ll learn multiple methods for turning off formatting on your posts and pages, complete with step-by-step instructions and expert tips. By the end, you‘ll be fully equipped to display your content pixel-perfect, every time.
Why You‘d Want to Turn Off WordPress‘s Automatic Formatting
According to WordPress.org, the software applies the following automatic formatting to your content by default:
| Formatting Change | Example |
|---|---|
| Curly quotes | "Hello" becomes "Hello" |
| Apostrophes | Sam‘s becomes Sam‘s |
| Em dashes | — becomes — |
| En dashes | — becomes – |
tags | Adds tags to paragraphs |
Most of the time, these formatting tweaks are harmless or even helpful for making your content look polished and consistently formatted.
But there are times when you definitely do NOT want WordPress messing with your carefully crafted content.
Here are some of the top complaints I hear from WordPress users about automatic formatting:
1. It breaks code snippets and custom HTML
If you‘re writing a tutorial or documentation that includes code samples, automatic formatting is your enemy. Let‘s say you want to include this bit of HTML in a post to demonstrate an image tag:
<img src="example.jpg" alt="Example image">With WordPress‘s default formatting, those straight quotes would be converted into curly quotes, breaking the code:
<img src="example.jpg" alt="Example image">To preserve your code formatting, those curly quotes and other formatting changes need to be disabled.
2. It messes up content pasted from other sources
Maybe you wrote your content in Google Docs, Microsoft Word, or another platform before pasting it into WordPress. Or perhaps you‘re migrating content from another website.
When you paste that content into the WordPress editor, it can end up looking very different than the original version as WordPress applies its own formatting. It‘s frustrating to then have to go back through and try to fix the formatting issues.
Disabling automatic formatting ensures your pasted content looks just like it did in the original source.
3. It interferes with page builders and custom designs
Many WordPress sites use page builder plugins or custom HTML and CSS to create uniquely designed pages.
Automatic formatting can wreak havoc on those custom designs by adding extra HTML tags and modifying your custom code. It‘s better to disable formatting entirely to let your page builder or custom code work as intended.
According to a survey by Search Engine Journal, 46% of web developers have encountered issues with WordPress‘s automatic formatting interfering with their custom-coded designs. Turning off formatting is essential to avoid broken layouts and styling.
4. It‘s incompatible with Markdown
Markdown is a popular way to format content using simplified syntax that is then converted into HTML. Plenty of writers compose their posts in Markdown format before converting to HTML for publishing.
But WordPress‘s default formatting doesn‘t play nicely with Markdown syntax. It can convert your Markdown-style links, images, and more into a jumbled mess.
If you‘re using Markdown, you‘ll definitely want to disable WordPress‘s formatting to preserve your content.
How to Disable WordPress‘s Automatic Formatting
Convinced that you need to turn off automatic formatting for some or all of your WordPress content? Here are two methods you can use:
- Manually by adding a code snippet
- Using a plugin
Each method has its own pros and cons, so choose the one that works best for your needs and comfort level.
Method 1: Disable Formatting Manually With Code
This method requires adding a snippet of code to your WordPress site to instruct it to stop automatically formatting your content. You can add this code snippet to your theme‘s functions.php file or by using a plugin like Code Snippets.
Here are the steps for disabling formatting with the Code Snippets plugin:
Install and activate the free Code Snippets plugin. Go to Plugins → Add New, search for "Code Snippets", and install and activate the first result.
In your WordPress dashboard, go to Snippets → Add New.
Give your snippet a name like "Disable Automatic Formatting" and paste in the following code:
function my_formatter($content) {
$new_content = ‘‘;
$pattern_full = ‘{(\[raw\].*?\[/raw\])}is‘;
$pattern_contents = ‘{\[raw\](.*?)\[/raw\]}is‘;
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
}
}
return $new_content;
}
remove_filter(‘the_content‘, ‘wpautop‘);
remove_filter(‘the_content‘, ‘wptexturize‘);
add_filter(‘the_content‘, ‘my_formatter‘, 99);- Set the language to PHP, choose Only run on site front-end, and make sure the snippet is activated. Click Save Changes.

With this snippet active, WordPress will no longer auto-format any content that you wrap in [raw] shortcodes. For example, to preserve the formatting of a code sample, you would enter it like this in the WordPress editor:
[raw]
<img src="example.jpg" alt="Example image">
[/raw]Anything outside the [raw] shortcodes will still have the default formatting applied, so you can pick and choose which content to exclude from formatting.
There are a few important things to keep in mind with this method:
- It only works if you‘re using the Classic Editor in WordPress. If you‘ve upgraded to the new Block Editor, you‘ll need to install the Classic Editor plugin to use this method.
- Adding custom code to your WordPress site always comes with risks. Make sure to test on a staging site and keep backups in case something goes wrong.
- You‘ll need to manually wrap every piece of content you want unformatted in the [raw] shortcodes, which can get tedious.
That said, the manual code method is a solid choice if you only need to disable formatting for certain bits of content or want to avoid adding another plugin to your site.
For an even deeper dive into adding code snippets to disable formatting, check out the detailed developer documentation at GeeksForGeeks.
Method 2: Disable Automatic Formatting With Plugins
If you‘re not comfortable editing code or want a simpler solution, there are also several WordPress plugins that can disable automatic formatting with just a few clicks.
Here are a couple of the most popular and well-reviewed options.
Option 1: Raw HTML by Janis Elsts
The free Raw HTML plugin makes it easy to disable automatic formatting for specific sections of content using shortcodes, with no code editing required.
To use it:
- Install and activate the Raw HTML plugin.
- Open the classic WordPress editor and switch to the Text tab.
- Wrap any content you want unformatted in [raw] shortcodes like this:
[raw]
<img src="example.jpg" alt="An example>
[/raw]- Switch back to the Visual tab to see your content without formatting applied.
Raw HTML has great reviews from users, with an average 4.8 star rating. One user raved:
"Works like a charm, and saves me having to edit my code every time I write a new post! I don‘t know why the visual editor has to mess up code blocks so badly, but this is the perfect solution."
The main downside of Raw HTML is that it can‘t disable formatting universally across your site. You‘ll need to manually add the [raw] shortcodes anywhere you want to preserve your content. But for most users, it‘s a simple, code-free solution.
Option 2: Preserved HTML Editor Markup Plus
For a more automatic, site-wide approach, check out the free Preserved HTML Editor Markup Plus plugin. Once activated, this plugin disables several of WordPress‘s automatic formatting functions automatically, no shortcodes needed.
To use it:
- Install and activate Preserved HTML Editor Markup Plus.
- That‘s it! The plugin will start working immediately to prevent WordPress from messing with your content.
According to the WordPress.org stats, Preserved HTML Editor Markup Plus has over 10,000 active installations with a 4.5 star average review.
One happy user said:
"I‘ve been using this plugin for a few months now and it does exactly what it says. It preserves the HTML from the editor when rendering the content. No more unwanted paragraph tags or line breaks. I would highly recommend it to anyone."
The tradeoff with this plugin is that it disables formatting universally as long as it‘s active. You won‘t be able to selectively format certain content. And some users have reported that it doesn‘t play nicely with the new WordPress block editor, so it‘s best used with the Classic Editor.
Which Method Should You Use to Turn Off Formatting?
Now that you know two ways to disable WordPress‘s automatic formatting, which one should you choose? It really depends on your unique situation.
If you just need to turn off formatting for a few pieces of content here and there, the manual code snippet method or the Raw HTML plugin are good choices. They let you turn off formatting only where needed so you can still take advantage of WordPress‘s formatting elsewhere.
But if you want to completely disable formatting everywhere and don‘t mind giving up those features altogether, the Preserved HTML Editor Markup Plus plugin is the most hands-off solution. Just be aware that it may not be 100% compatible with the block editor if you ever want to switch to that method of post creation.
Whichever method you choose, I recommend the following best practices for disabling automatic formatting in WordPress:
- Always test on a staging site first before making changes to a live site. You don‘t want to accidentally break your site for visitors.
- Keep full backups of your site before disabling formatting in case you need to undo your changes.
- If adding custom code, use a child theme to avoid losing your changes when updating your theme.
- Consider installing the free Classic Editor plugin for maximum compatibility with plugins and code snippets that disable formatting.
- Only turn off formatting when absolutely necessary. The default formatting is fine for most content and turning it off universally can cause issues in the long run.
Wrapping Up
WordPress‘s automatic formatting features can be super handy for cleaning up your content and ensuring proper HTML structure. But there are definitely times when you need to preserve your content exactly how you entered it, funky formatting and all.
In this guide, we‘ve covered:
- Common reasons for disabling automatic formatting like writing code snippets, using page builders, or converting Markdown
- Two methods for turning off formatting:
- Manually with a code snippet
- Using the Raw HTML or Preserved HTML Editor Markup Plus plugins
- Step-by-step instructions and expert tips for each method
- Best practices for safely disabling formatting on your WordPress site
By now, you should feel armed and ready to take control of your content formatting. Whether you opt for the manual code route or the plugin approach, you can say goodbye to WordPress messing with your carefully crafted posts and pages.
Just remember to always test changes on a staging site, keep backups, and only disable formatting when you really need to. Used strategically, disabling auto-formatting is a handy trick for WordPress power users like yourself to have up your sleeve.
