How to find and replace in block editor content safely
Why a plain text search can break WordPress block markup, what to protect, and a safe routine for changing text, links and image URLs.
Quick answer: back up first, replace in the text or the URLs only, not in the block comments, and test on a copy before you run it on the live site. A plain database search and replace can break blocks.
What block markup looks like
Block editor content is stored as HTML with comments such as <!-- wp:image {"id":123} -->. The comment holds settings in JSON, and the HTML after it must match what the block expects. If a replacement changes one but not the other, the editor can report that the block contains unexpected content.
Where replacements go wrong
- Replacing inside JSON attributes and leaving the HTML different.
- Changing the length of serialized data such as PHP arrays, which stores string lengths.
- Matching too much: a short term like "blue" also changes class names and URLs.
- Case and partial matches hitting words you did not intend.
A safe routine
- Back up the database or the single post.
- Paste a sample of the markup into the find and replace tool and run the replacement on it first.
- Choose the scope: text only, links only or image URLs only, so attributes and structure stay untouched.
- Check the result in the preview, with one term at a time if you have several.
- Open the post in the editor and confirm the blocks still load without a recovery warning.
Moving a site to a new domain
For a domain change or an http to https upgrade, use the URL migration tool. It swaps the old domain for the new one across links, images, srcset and other attributes in block markup.
Everything stays in your browser
The tool works on text you paste, and nothing is uploaded. Paste the changed markup back into the post, or use the WordPress plugin for bulk changes across a whole site.