Cleaning up Formatting Shortcodes

There are many reasons not to like Visual Composer or any other plugin that uses shortcodes for formatting purposes in the WordPress content editor. One of them is that it can be a lot of work cleaning up the mess of shortcodes that they leave if you ever decide to deactivate the plugin. But how can can remove shortcodes without painfully selecting and deleting each one?

Here is a handy regex expression that can save some time and leave you with the original unformatted content.



\[ : [ is what is known as a meta character which is used to group things in regex. for example [a-z] means a through z. In order to match it literally we need to “escape it” which can be done by using \

(.*?) : matches everything in a “non-greedy” way and captures it. You can read about different ways of matching below but basically we want to make sure that it only captures what is inside the brackets and not the content between the sets of brackets (all of our content.)

\] : Here we are escaping another meta character ] to match it literally.

That’s nice. Just tell me how to do it.

In order to do this you will need to copy the entire content of the editor into a code editor. I find Sublime Text to be the easiest to use for finding and replacing using regex expressions. You may want to check that your code editor has this functionality before proceeding. Add the expression above into the “find” input and “find all.”

Click delete. (Warning: this will delete all shortcodes!)

Admire your nice, clean, shortcode-free, content.

5 comments on “Cleaning up Formatting Shortcodes

  1. This deserves a loud golf clap as I just tried this using Sublime Text and a csv export of “visual composer” saturated content.

    Worked beautifully!

    Left a few dbl space items floating around, however nothing a little regex cleanup can’t fix. This is the most complete solution for an developer migrating content from the “lock-in” of drag/drop editors…grazie again!

  2. Hi, thank you for the info. I would like to try it since I want to stop using wpbakery but it leaves al the shortcodes in my content. Just one question, I have more than 1000 posts on my site, do I need to do this one by one? or is there a way to do the whole website at once?
    Hope you can help me out here. Thank you so much!

    • Hi Celina, yes, I’m afraid you would indeed have to do this post by post if you went through your code editor. You could, however, write a script that would do a find and replace in each of your posts using a tool like WP-CLI and use the same Regex. It’s a bit trickier but I’m sure you could do it in less time than it would take you to go through 1000 posts 😉 Practice first though and be sure to back up your database.

  3. Many thanks for the great tip Kirsten! You should be very proud of yourself considering how relevant this article is even after 5 years since its posting…and how awful Visual Composer is that we still have to go and manually remove their mess!

    For those who are using Visual Studio Code, you need to click the little asterisk in the Find box (or press Alt + R) to use regular expressions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Click to view allowed tags

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.