Ir para o conteúdo
DevTools / Formatador e validador de JSON

Formatador e validador de JSON

A malformed JSON document is the most common single cause of a failed API call, and the error message a runtime gives you — unexpected token at position 4721 — is rarely enough to find the problem in a 200 KB response. This formatter validates with a line and column number, pretty-prints with your choice of indentation, minifies for transport, lets you collapse and drill into a tree, runs JSONPath queries against the parsed document, and reports statistics such as key count, maximum depth and payload size.

Roda inteiramente no navegador — nada é enviado.

Entrada
Saída

JSONPath extraction

Examples: $.tools[*].id · $..category · $.tools[?(@.featured==true)].id · $.locales[0:3]

Como funciona

JSON has a small grammar, and almost every parse error reduces to one of four causes: a trailing comma before a closing brace or bracket, a single-quoted string, an unquoted object key, or a comment. None of these are legal in JSON even though they are all legal in JavaScript object literals, which is why a snippet copied from source code so often fails. This tool reports the offset, line and column of the first offending character and shows the surrounding text, which usually makes the cause obvious at a glance.

Beautifying inserts whitespace between tokens without changing what they mean. Minifying strips every byte that the grammar does not require, including the spaces in pretty-printed output, and typically removes 30 to 60 percent of the size of a formatted document. Neither operation touches string contents, numbers or key order — a formatter that reorders keys or rewrites numbers is doing something wrong, because object key order and numeric precision are both observable to the receiving program.

The tree view exists because reading a large document as text does not scale. Collapsing an object hides its subtree so you can navigate to the branch you care about, and the path of each node is shown so you can copy a reference to it. For programmatic queries, JSONPath expressions such as $.items[?(@.price > 100)].sku select nodes across the whole document, including through arrays and wildcards, which is far faster than scrolling when you need every occurrence of a field rather than one specific location.

One caveat worth knowing: JavaScript numbers are IEEE-754 doubles, so integers beyond 2^53 lose precision when parsed. A Twitter/X snowflake ID or a database bigint will come back subtly wrong — 1234567890123456789 becomes 1234567890123456800. This tool detects integers outside the safe range and warns rather than silently rounding, because the failure is invisible until an ID fails to match in a database lookup.

Casos de uso comuns

  • Format a minified API response so you can read the structure and find the field you need.
  • Locate the exact character that makes a config file fail to parse at deploy time.
  • Minify a JSON fixture before embedding it in a test or a seed script.
  • Run a JSONPath query to extract every matching value from a deeply nested response.
  • Check whether a payload contains a number large enough to lose precision in JavaScript.
  • Compare the key count and depth of two responses to see how a schema changed between versions.

Última atualização: 2026-10-14 — o corpo do artigo é exibido em inglês; a interface está traduzida.

Perguntas frequentes

Why does my JSON fail to parse when it looks correct?

The four usual culprits are a trailing comma after the last item in an object or array, single quotes around a string, an unquoted key, and a comment. None are permitted by RFC 8259, though JSON5, JSONC and JavaScript all allow them. A fifth possibility is an invisible character: a byte-order mark at the start of a file, or a non-breaking space copied from a document, both produce errors that look impossible when reading the text.

Does formatting change the data?

No. Whitespace between tokens is insignificant in JSON, so beautifying and minifying are exactly inverse operations on any valid document. Ordering of object keys is also preserved, which matters because some systems are sensitive to it — for example when a canonical form is hashed for a signature. What formatting does not do is reorder arrays: array order is data, and no correct formatter will ever change it.

What is JSONPath and how is it different from a simple search?

JSONPath is a query language for JSON, roughly what XPath is for XML. A filter expression such as $.orders[?(@.total > 500)].id walks the document structure and returns every matching node rather than the first textual occurrence of a string. That matters because a plain text search cannot distinguish a field named id from a value that happens to contain the letters id, while JSONPath operates on the parsed tree and understands types.

Is my data sent anywhere?

No. Parsing, formatting and querying all run in JavaScript in your browser, and the page issues no network request while you work. This is worth insisting on for a JSON tool in particular, because API responses routinely contain access tokens, personal data and internal hostnames, and a server-side formatter would receive all of it. You can verify the claim by opening your browser's network panel.

Ferramentas relacionadas