How to clean up WordPress HTML with the Puritext API
If you're managing content in WordPress, you've probably encountered copy-pasted formatting disasters: inline styles, Word artifacts, weird symbols, and inconsistent spacing. Puritext API helps you automate the cleaning process and keep your CMS code tidy.
Step 1 – Get your API token
Log into your account and copy your API token (available only to PRO users).
Step 2 – Set up your script
Here's a simple `curl` command you can use to clean HTML:
curl -X POST https://puritext.com/api/clean \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "<p style=\"font-family:Calibri\">Hello from Word! 😬</p>",
"format": "cms",
"remove_html": false,
"remove_emoji": true,
"remove_symbols": true,
"normalize_quotes": true,
"remove_double_spaces": true
}'
Step 3 – Paste the result
Use the cleaned output as your new post content in WordPress (in HTML view). All garbage is gone, but rich elements like <p>
, <strong>
or <a>
are preserved.
Extra tip: Batch process
If you have dozens of posts to clean, use the same API call in a loop. Read from your database, clean via Puritext, and save back.
Questions? Contact us or check out the full API documentation.