Toolivaro

Formateador y validador de JSON gratis

Formatea y valida JSON con sangría legible, mensajes de error precisos y estadísticas de tamaño en bytes, todo local.

El formateador de JSON convierte JSON comprimido o roto a mano en una salida legible con sangría de dos espacios, y lo valida al mismo tiempo. Pega cualquier documento JSON —una respuesta de API, un archivo de configuración o un fixture de pruebas— y se analiza y embellece al instante, con un mensaje de error claro y su posición cuando el documento no es válido. La herramienta informa de los tamaños de entrada, con formato y minimizado en bytes, para que veas exactamente cuánto cuesta el espacio en blanco, y ofrece acciones de copiar y descargar para el resultado. Todo se ejecuta localmente en tu navegador: el JSON pegado nunca sale de tu dispositivo, no se registra ni se envía a ningún sitio —algo que importa cuando el documento contiene tokens, claves privadas o datos personales. La validación sigue la semántica de JSON.parse, así que la herramienta acepta exactamente lo que acepta la plataforma (RFC 8259, incluidas cadenas, números, arrays, objetos y null). Usa esta herramienta para depurar una respuesta de API, revisar un archivo de configuración o preparar JSON para una pull request.

Se procesa localmente en tu navegador

Procesado localmente en tu navegador: el JSON pegado nunca se sube, registra ni almacena.

Cómo usar esta calculadora

When the JSON formatter earns its place

Every developer has hit the wall of a single-line API response: hundreds of characters of JSON with no whitespace, and the one field you need hiding somewhere in the middle. That is the formatter’s home turf. Paste the response in, and the tool re-indents every object and array with two spaces so the structure becomes visible at a glance — which property lives in which object, and how deep the nesting goes. The same action validates the document, so a config file you edited by hand is checked for grammar at the same time. Reviewing a pull request? A formatted copy makes the diff legible instead of a wall of text. Extracting an error payload from a failed request? Same flow. Because everything runs locally, this is also the safe option for documents that carry API tokens, private keys, or personal data — nothing is uploaded, logged, or stored, so you can format a credential-bearing fixture without shipping it anywhere.

The tool is deliberately strict: it accepts standard JSON only, with the same grammar the browser’s JSON.parse accepts. That strictness is the feature. A document that parses here will parse in any JavaScript runtime, in Node, and in most CI tooling — which makes the tool a cheap pre-commit gate. It is equally useful the other way around: when a server or a script hands you JSON that fails to parse, the formatter tells you exactly where the grammar breaks, so you can fix the source rather than the symptom. Keep it in mind whenever you copy JSON out of a database, a generated file, or an email and want to know it is intact before it goes anywhere. If your text is close to JSON but not JSON — YAML, JSON5, a config file with comments — this is the wrong tool, and it will tell you so.

Formatting a document, step by step

Open the tool and paste your JSON into the input textarea — that is the only required field. Then click Format. If the document is valid, the formatted result appears in the output box below, indented with two spaces, and the stats row under it reports the input size, line count, minified size, and formatted size in bytes. Two further actions matter. Validate checks grammar without producing output — the answer you want when you only need a yes-or-no before committing a file. Clear empties both boxes and returns focus to the input, which is faster than selecting text by hand between runs. Once you are happy, Copy puts the formatted text on your clipboard, and Download saves it as a .json file named toolivaro-format.json — handy when you want to drop a cleaned-up fixture into a repository or an issue.

The most common missteps show up immediately. Paste nothing and click Format, and the tool answers with “Paste some JSON first.” — a gentle nudge rather than an error. Paste invalid JSON, and no output is produced; instead the tool reports the parser’s message with a position, like (position 66), so you can find the exact character that breaks the grammar. Trailing commas, single-quoted strings, unquoted keys, and comments are all rejected on purpose — this tool does not guess what you meant the way a permissive formatter might. Expect two-space indentation only; there is no setting for tabs or four spaces in this version. And remember that the input box accepts whatever you paste, so confirm you pasted the whole document — truncating a large response at the start or end produces a validation error that is really a copy problem.

Two details make the workflow predictable. The tool keeps no history between visits: there is no autosave, no paste log, and nothing survives a page reload — open the page, format, close, and the document is gone with the tab. That is intentional and worth leaning on: it makes the formatter safe to use with tokens or private keys without worrying about a browser-stored copy of them. And the Copy action writes exactly what the output box shows, so what you paste elsewhere is what you saw on screen — the formatted document, nothing re-validated or re-indented behind your back. Download saves the same content to a file, which is the cleanest way to hand a cleaned-up fixture to a repository or an issue.

Reading the output, the stats, and the errors

The output box holds the formatted document: one property per line, nested objects and arrays indented two spaces per level, and every string, number, and boolean exactly as it was in the input. Formatting never changes the data — for valid JSON the parse-and-re-stringify round trip is lossless, so the formatted copy is the same document with whitespace added. The stats row tells you what readability costs: “Input 61 B · 1 line · minified 61 B (−0%) · formatted 78 B” means the compressed form is 61 bytes and the pretty form 78. The size-comparison bars show the same relationship visually, scaling both against the larger. A gap of 17 bytes on a small payload is nothing; on a big API payload, minified output can matter for storage or transfer budgets — which is why the tool always shows both.

Errors are the other half of reading the output. When the parser rejects the document, the tool shows the engine’s message plus a position — “Expected double-quoted property name in JSON at position 66 (position 66)” for a trailing comma, for instance — and marks the input as invalid. The exact wording comes from the browser’s own JSON parser, so it can differ slightly across engines, but the position always points at the character where parsing stopped. Two limits are worth knowing. First, validation is grammatical, not semantic: a document that parses can still be wrong for your application — the wrong key, the wrong type — and no tool can catch that for you. Second, documents of hundreds of megabytes will slow the browser, so the tool is designed for typical configs and API payloads rather than database dumps.

¿Cómo se calcula el resultado?

Formatear una respuesta de API comprimida

Una API devuelve {"status":"ok","items":[{"id":1,"name":"A"},{"id":2,"name":"B"}]}. El formateador produce una propiedad por línea con sangría de dos espacios, haciendo visible el anidamiento de un vistazo. El panel de estadísticas muestra que la entrada ocupa 68 bytes mientras que la versión formateada ocupa 101: el coste en espacio de la legibilidad.

Entrada y resultado del ejemplo
Entrada Valor
json {"status":"ok","items":[{"id":1,"name":"A"},{"id":2,"name":"B"}]}
Resultado JSON válido · con sangría de 2 espacios · entrada de 68 B → salida de 101 B

Formatting a Unicode-heavy API response

A weather service returns conditions for several cities in a single minified line, including names in their local spellings: München, José, and a fire emoji for the alert level. Pasted as-is, the payload is one dense line, and the accented characters make it easy to lose your place. Format the payload and the tool expands it to one property per line, so the four fields — city, temp, emoji, name — become instantly readable. The stats row then tells a story that surprises people the first time: the input weighs 61 bytes but is only 57 characters. Bytes are like postage stamps: a letter’s weight depends on the characters inside it, not just on how many there are. The ü in München takes two bytes, the é in José two, and the fire emoji four, while plain ASCII letters take one each. The formatted copy comes in at 78 bytes, all of it readable UTF-8. That distinction matters in practice: when you minify and store the payload later, byte size — not character count — is what your database column and your transfer limits see. The stats row shows both figures side by side, so you can weigh readability against size before the result goes anywhere. The example also shows validation passing silently: the payload parses on the first Format click, so the tool goes straight to output, and a quick Copy drops the readable version into a ticket or a pull request description. No settings are needed, and there is nothing to configure: paste, format, read the stats, copy. That one-click round trip is the point of a local utility.

Entrada y resultado del ejemplo
Entrada Valor
json {"city":"München","temp":23.5,"emoji":"🔥","name":"José"}
Resultado Valid JSON · formatted with 2-space indent · input 61 B → formatted 78 B

Tracking down a validation error after a hand edit

Hand-editing a generated config file — an environment file listing services and deployment regions — is where trailing commas sneak in. You add one more region to the array and, out of habit, leave the comma that used to precede the closing bracket: the array now ends with a comma, then a brace. The formatter refuses to produce output and instead reports the parser’s message with a position: “Expected double-quoted property name in JSON at position 66 (position 66)”. Read it like a copy editor proofreading a headline twice: the message names the exact problem, and the position pinpoints it. The parser reached the end of the array, found a comma, then found the closing brace where another property name should have been. Position 66 is where that unexpected brace sits, counting characters from the start of the document, and the stray comma at position 65 caused it — delete the comma and the document parses. The tool marks the input as invalid and leaves the output box empty, so there is no half-formatted result to mislead you. The fix is mechanical, not a hunt: go to the reported character, look one step back for the stray punctuation, and remove it. Validate is the cheap way to run this check without reformatting anything: click Validate, see the error, fix the text, click again, and the tool answers “Valid JSON.” That loop — paste, validate, fix, validate — is the fastest way to clean up hand-edited configuration before it goes anywhere near a server, and it works for any of the classic grammar slips: trailing commas, single quotes, unquoted keys, comments. The error message always tells you where to look, never just that something is wrong.

Entrada y resultado del ejemplo
Entrada Valor
json {"service":"api","env":"prod","regions":["us-east-1","eu-west-1"],}
Resultado Invalid JSON — Expected double-quoted property name in JSON at position 66 (position 66)

¿Cuál es la fórmula y sus supuestos?

Método de formato

format(json) = JSON.stringify(parse(json), null, 2)

Términos de la fórmula
Símbolo Significado
parse analizador JSON estándar (semántica RFC 8259)
null, 2 sin función replacer; sangría de dos espacios

El formato nunca cambia los datos: analizar y volver a serializar es un viaje de ida y vuelta sin pérdidas para JSON válido.

Validación

valid ⇔ parse(json) succeeds

Términos de la fórmula
Símbolo Significado
valid JSON gramaticalmente correcto según RFC 8259

Un JSON sintácticamente válido puede seguir siendo semánticamente incorrecto para tu aplicación: la validación comprueba la gramática, no el significado.

¿Cuáles son los errores más comunes?

  • Pegar JSON con comas finales o comentarios y esperar que se analice: el JSON estándar rechaza ambos.
  • Tratar la validez sintáctica como corrección semántica: un documento válido puede seguir sin cumplir el esquema de tu aplicación.
  • Formatear datos sensibles con una herramienta en línea que los sube: esta herramienta nunca envía nada a ningún sitio.

¿Cuáles son los supuestos y las limitaciones?

  • La validación es gramatical (RFC 8259), no semántica: no puede juzgar si los datos coinciden con tu esquema.
  • Los documentos muy grandes (cientos de MB) pueden ralentizar el navegador; la herramienta está pensada para configuraciones y cargas de API típicas.
  • La salida usa únicamente sangría de dos espacios; otros estilos de sangría no son configurables en la versión 1.

¿De dónde salen los números?

Última revisión 12 de agosto de 2026 · Versión 1.1.0 · Toolivaro no garantiza el contenido externo.

Preguntas frecuentes

¿Es seguro formatear JSON con claves duplicadas?

El analizador conserva el último valor de una clave duplicada (comportamiento JSON estándar), y el formateador preserva exactamente lo que el analizador aceptó. Si las claves duplicadas te importan, valida con tu propio esquema: JSON en sí no las prohíbe.

¿Por qué mi JSON falla la validación?

Causas habituales: comas finales, cadenas con comillas simples, claves sin comillas, comentarios y basura sobrante tras el documento. El mensaje de error incluye la posición del analizador cuando está disponible, para que saltes directamente al problema.

¿Esta herramienta admite JSON5 o YAML?

No: esta herramienta solo acepta JSON estándar. Los comentarios y las comas finales son características de JSON5 y se rechazan a propósito; usa un conversor específico para esos formatos.

Why do the byte counts look higher than my character count?

Because bytes and characters are not the same thing. The tool measures size in UTF-8 bytes: ASCII letters and digits take one byte each, while accented characters like ü or é take two, and emoji take four. A 57-character document can therefore weigh 61 bytes. The byte figure is what storage and transfer limits actually use, so it is the honest number to compare.

What is the difference between Format and Validate?

Format parses the document, checks the grammar, and writes the pretty-printed result into the output box with full size stats. Validate runs the same parse but reports only a verdict — “Valid JSON.” or an error with position — and leaves the output box untouched. Use Validate when you want a quick check without reformatting, for example before committing a config file you already formatted.

How large a document can I format?

There is no hard cap, but the tool parses synchronously in the browser, so very large documents — hundreds of megabytes — will slow the page and may freeze the tab for a while. It is designed for typical configs and API payloads. For multi-gigabyte dumps, use a streaming parser in a script instead; anything you can paste, this tool handles.

Parte de Kit de herramientas de texto y JSON para desarrolladores

¿Encontraste un error o tienes una corrección? Repórtalo: revisamos cada corrección.

¿Te ha sido útil?

Revisado por el equipo editorial de Toolivaro según nuestra metodología Metodología · Política editorial