Block import fails with an invalid JSON error
In short
These errors mean the file isn't .json, the JSON is broken, or you used the wrong import tool. Whole-block files go into More actions → Import; blocks-only files go into ⋯ → Import blocks.
✓ Applies to
- More actions → Import in the block editor
- ⋯ → Import blocks next to Add block, including the Paste JSON tab
✕ Doesn't apply to
- Blocks that import fine but don't show in checkout
Match the file to the import tool
Most failures are this. Each tool only reads its own kind of file.
| Exported with | Import with | File starts with |
|---|---|---|
| More actions → Export (whole block) | More actions → Import | { |
| ⋯ → Export blocks (blocks only) | ⋯ → Import blocks | [ |
Error → fix
- Found: 0 block(s), then Invalid JSON file format in Import blocks → it’s a whole-block file. Use More actions → Import.
- Found: 0 block(s), 0 rule(s) in More actions → Import, nothing added → it’s a blocks-only file. Use ⋯ → Import blocks, or paste the array into Paste JSON.
- Invalid JSON format or a greyed-out Import on Paste JSON → the JSON is broken. Often a trailing comma, comment, single quotes, part of the file copied, or a word processor changed the quotes. Export again instead of editing by hand.
- Please select a valid JSON file → the file isn’t
.json. Rename it back to.json. - Found: 0 block(s) and the file is just
[]→ the exported block was empty. Export one that has blocks.
Success looks like 2 block(s) appended successfully. Then click Save. The import isn’t kept until you do.
Frequently asked
What format does Paste JSON expect? +
A JSON array of blocks, starting with [ and ending with ]. That's what ⋯ → Export blocks produces. A whole-block export, which starts with {, won't work there.
Why is the Import button greyed out on the Paste JSON tab? +
The pasted text isn't valid JSON yet. While it's invalid, the help text under JSON content reads 'Paste a valid JSON array of blocks'.
Can I edit an exported file by hand? +
Yes, but keep it valid JSON. Trailing commas, comments and single quotes all make the import fail.