Loading Techie Utils…

XML Repair

Fix broken XML and see a list of every repair that was made. Free, and runs entirely in your browser — nothing you enter is uploaded or stored.

About Structure Repair

Takes a document that does not parse and applies a set of well-understood fixes: trailing commas, single quotes and comments in JSON; tabs and missing spaces after a colon in YAML; bare ampersands, control characters and unclosed tags in XML. Every repair is listed, so nothing happens silently.

The configuration formats get the fixes their own mistakes call for. TOML: key: value written YAML-style, unquoted strings, True and null, a table header missing its bracket, a string left open, a trailing comma in an inline table. TOON: tabs, an open quote, and a [count] that no longer matches the rows under it — corrected to what is there, and flagged, because the other explanation is a document that was cut short. INI: an open section heading, a forgotten =, // comments and lines that are nothing at all. .env: NAME: value, a Windows set prefix, names a shell rejects, a quote that never closes, and a variable set twice. .properties: [sections] pasted in from INI are unfolded into key prefixes, and a backslash that escapes nothing — the one that silently turns C:\users into C:users — is doubled. HCL: key: value, 'single quotes', a capitalised True, a ; at the end of a line, a heredoc that never reached its marker, and blocks left open at the end of a paste.

.env and .properties are written back with their own keys, in their own order. Neither goes through the tree the converter uses, because that would upper-case .env names and re-nest dotted keys — a conversion rather than a repair.

The output is re-parsed before it is returned. If the repairs were not enough, you get the parser's error rather than a document that merely looks fixed.

Where it helps

  • Names every repair it made, so you can judge whether it did the right thing.
  • Re-parses the result, so it never hands back something that still fails.
  • Unclosed XML tags are closed in the order the document opened them, and the result is re-parsed to prove it.
  • Repairs and reformats in one pass, so the output is ready to commit.

Limits

  • It is a syntax repairer, not a mind reader — a document missing a closing brace in an ambiguous position may still fail.
  • Repairing changes the document; keep the original until you have checked the diff.
  • JSON comments and single quotes are removed rather than preserved, because strict JSON has no place for them.
  • YAML repair covers whitespace and quoting, not structural mistakes such as wrong indentation depth.
  • A TOON count is corrected to match the rows present, which fixes the parse but cannot bring back rows that were lost — the fix says so when it makes it.

Frequently asked questions

Is it safe to run on a document I care about?

The repairs are conservative and each one is reported, but compare the output against the original before replacing anything.

Why were my JSON comments deleted?

JSON has no comment syntax, so a document containing them is not JSON. If you need comments, JSON5 or YAML is the right format.

It still fails after repairing. What now?

The error message points at the line that defeated it. Structural problems — a brace closing the wrong block — need a human decision, which is why nothing is guessed.

How does it decide which tag to close?

It tracks the tags the document opened and closes them in reverse order, then re-parses the result. If that does not produce a valid document, you get the parser's error rather than a guess.

Related tools

  • Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
  • Structure Formatter — Pretty-print JSON, XML, YAML, TOML, TOON or HCL with a chosen indent
  • Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
  • Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
  • Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
  • String Escaper — Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back

More Structured Formats tools

  • Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
  • String Escaper — Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back
  • Structure Formatter — Pretty-print JSON, XML, YAML, TOML, TOON or HCL with a chosen indent
  • Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
  • Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
  • Code Generator — Turn a JSON, YAML, XML or other document into TypeScript, Go, C#, Python, Rust and more
  • Schema Generator — Write a JSON Schema, XSD, Avro schema or .proto from a document you already have
  • Schema Validator — Check a document against a JSON Schema, .proto, Avro schema, XSD or RELAX NG
  • Table Viewer — Show the records in a JSON, XML, YAML, TOML or TOON document as a table
  • Structure Compare — Diff two JSON, XML, YAML, TOML, TOON or HCL documents by path
  • Structure Repair — Fix broken JSON, YAML, XML, TOML, TOON, INI, .env, .properties and HCL, listing every repair
  • Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
  • Path Finder — Select nodes with JSONPath or XPath
  • Protobuf & Avro Decoder — Read protobuf wire bytes and Avro container files without their schema
  • Expression Evaluator — Reduce a JSONPath or XPath match to a single answer