Formatador e validador JSON
Formate, valide e minifique JSON — com localização precisa de erros de sintaxe.
Sobre esta ferramenta
Cole qualquer JSON, obtenha uma versão formatada ou minificada. JSON inválido é destacado com a linha e coluna exatas do erro. Funciona com arquivos de até 10 MB.
Como usar
- 1 Cole seu texto JSON na área de entrada.
- 2 Clique em Embelezar para uma saída indentada legível, ou em Minificar para remover espaços em branco.
- 3 Se houver um erro, a linha e coluna exatas serão destacadas.
- 4 Clique em Copiar para copiar o JSON formatado para sua área de transferência.
What "formatting" JSON actually does
JSON (JavaScript Object Notation) is a plain-text format for structured data: nested objects in curly braces, arrays in square brackets, and key/value pairs separated by commas. A machine doesn't care whether that text is squeezed onto one line or spread across fifty — both parse to the same data. Formatting changes only the whitespace between tokens. Beautifying inserts newlines and indentation so a human can read the structure; minifying removes every optional space so the payload is as small as possible. This tool does both by parsing your text into a real object with the browser's native JSON.parse(), then re-serialising it with JSON.stringify() — either with two-space indentation or with none.
Because it round-trips through a genuine parser, formatting here is also validation. If the parser can't read your text, it can't reformat it, and you get the exact error message instead. Everything runs locally in your browser; the JSON you paste is never uploaded.
A worked example
Paste this minified line:
{"user":{"name":"Ada","roles":["admin","editor"],"active":true},"count":2}
Beautify turns it into a readable tree:
useris an object containingname,roles, andactiverolesis an array of two stringsactiveis the booleantrue(not the string"true")countis the number2
Minify reverses the process, collapsing it back to the single compact line — useful when you need to embed JSON in a URL, a config value, or an API request body where every byte counts. The tool also reports the input size in bytes, so you can see exactly how much minifying saves.
Reading and fixing validation errors
The most valuable feature is the error message, because malformed JSON is the cause of countless silent API failures. The parser pinpoints where it gave up. The usual culprits:
- Trailing comma.
{"a":1,}is invalid — JSON forbids a comma before a closing brace or bracket, even though JavaScript object literals allow it. - Single quotes. Keys and strings must use double quotes.
{'a':1}fails; it must be{"a":1}. - Unquoted keys.
{a:1}is a JavaScript object literal, not JSON. Every key needs quotes. - Missing or extra comma between items. The error usually points at the token right after the problem, so check the line just before the reported position.
- Smart quotes. Pasting from a word processor can replace
"with curly“ ”, which the parser rejects.
Why JSON forbids comments
A frequent surprise: // like this or /* this */ will not parse. Comments were deliberately left out of the JSON spec so the format stays a pure, unambiguous data interchange. If your file has comments, it is really JSONC (JSON with Comments, used by tools like VS Code's settings) or JSON5. Strip the comments before formatting here, or use an editor that understands those relaxed dialects. The same applies to trailing commas, which JSON5 permits but standard JSON does not.
Practical use cases
- Debugging API responses. Paste a one-line response from a server log and beautify it to see the structure at a glance.
- Cleaning up before committing. Reformat configuration files (
package.json,tsconfig.json) so diffs stay consistent across a team. - Shrinking payloads. Minify a large config before pasting it into an environment variable or a query string.
- Sanity-checking generated JSON. Validate output from a script or an AI model before sending it downstream, catching syntax errors early.
Tips and common pitfalls
- Numbers keep their type. Note that re-serialising can normalise number formatting —
1.0becomes1, and very large integers may lose precision because JavaScript numbers are 64-bit floats. If you need exact big-integer fidelity, treat such values as strings. - Key order is preserved. The tool keeps your keys in their original order rather than sorting them, so the only change you see is whitespace.
- Duplicate keys collapse. If an object has the same key twice, the parser keeps only the last value — a silent data loss worth knowing about.
- Mind the size. Parsing happens in memory, so files past roughly 10 MB can make the browser sluggish. For multi-megabyte data, a command-line tool such as
jqis faster. - Validating isn't schema-checking. This tool confirms your JSON is syntactically correct, not that it matches the shape an API expects. For that, use JSON Schema validation.
Perguntas frequentes
Codifique ou decodifique strings Base64 — funciona para texto e arquivos.
Codifique ou decodifique URLs e parâmetros de consulta — modos completo e de componente.
Converta Markdown em HTML limpo — com prévia lado a lado em tempo real.