Formateador y validador JSON

Respuesta: JSON Formatter & Validator produce su salida instantáneamente a partir de la entrada que usted proporciona: todo se ejecuta en su navegador, de forma gratuita y sin necesidad de registrarse.

Formatee, valide, minimice y embellezca JSON al instante

Esperando entrada...
La salida formateada aparecerá aquí...
Ad

¿Qué es JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format that's easy for humans to read and write, and easy for machines to parse and generate. It's the standard format for APIs, configuration files, and data storage. JSON supports exactly six data types — strings, numbers, booleans, null, objects, and arrays — and its grammar is strict enough that a single misplaced comma or quote makes the whole document unparsable. That strictness is why a formatter with instant validation matters: it tells you not only that something is wrong but where the parser gave up.

Todo lo que hace este formateador sucede en su navegador. Su JSON nunca se carga, por lo que es seguro para las respuestas de API que contienen datos privados, credenciales en archivos de configuración o cargas útiles aún en desarrollo.

Formatear, minimizar y validar

Formatting (also called beautifying or pretty-printing) re-inserts indentation and line breaks so the structure of nested objects and arrays is visually obvious. Minifying does the opposite — it strips every byte that isn't required by the grammar, producing the smallest valid document for transmission. Validating parses the document and reports success or the exact position of the first syntax error without changing anything. All three operate on the same text, so you can round-trip freely: minify an API response to see its size, format it to read its structure, validate after every edit.

Errores JSON comunes

JSON estricto frente a JavaScript cotidiano

Muchos documentos que parecen JSON son en realidad objetos literales de JavaScript, y la diferencia es exactamente de dónde provienen la mayoría de los errores de validación. La siguiente tabla enumera las construcciones que JavaScript tolera pero que JSON prohíbe estrictamente.

ConstruirjavascriptJSON estrictoFix
Cadenas entre comillas simplesPermitidoInválidoUtilice comillas dobles
Claves sin comillasPermitidoInválidoCita cada clave
Comas al finalPermitidoInválidoEliminar la coma final
ComentariosPermitidoInválidoEliminar o pasar a un formato contenedor
Valores indefinidosPermitidoNo es un tipo JSONUtilice nulo u omita la clave
NaN / InfinitoPermitidoNúmeros no válidosUtilice nulo o una cadena

Cuando el tamaño importa: compensaciones por la minificación

Minified JSON is what APIs actually ship — indentation costs bytes on every request. But the savings only come from whitespace: minification does not rename keys, shorten strings, or restructure data. A large minified document and its formatted twin contain identical information, so gzip compression largely erases the difference on the wire; formatting matters most for local files, logs, and developer tooling rather than production transfer. A useful workflow is to keep source files formatted for readability and generate the minified version as a build step, exactly as you would with JavaScript or CSS.

JSON en el ecosistema

JSON's dominance means most adjacent formats are JSON with extensions. JSON5 relaxes the grammar for humans, permitting comments, trailing commas, and unquoted keys. JSON Lines (JSONL) stores one JSON value per line, popular for logs and streaming datasets. JSON with Padding (JSONP) is a legacy cross-domain technique that predates CORS and is now obsolete for new work. GeoJSON adds coordinate structures for geographic data, and JSON Schema describes the shape a document must have, enabling validation beyond mere syntax. A strict formatter like this one is the common denominator across all of them: syntax-level correctness is the first gate any of these formats must pass.

Lectura de JSON profundamente anidado

The practical pain of reading JSON scales with nesting depth. At two or three levels, indentation alone is enough. Beyond that, a few habits help: scan for the key you need at each level rather than reading linearly; note array boundaries early, since a misplaced bracket is the most common reason an expected key "disappears" (it lives in a sibling element of an array you skipped); and when hunting one value inside a huge document, format it, copy the path down as you descend, and paste the fragment into a scratch file. Errors reported at the end of a document usually mean an unterminated construct somewhere above — a missing closing brace or quote — which is exactly the case where a formatter's error position beats eyeballing.

Preguntas frecuentes

¿Mi JSON se envía a un servidor?

No. El formateo, la minimización y la validación se ejecutan localmente en su navegador con JavaScript. Nada de lo que pegue se transmite ni almacena, por lo que la herramienta es segura para los datos confidenciales.

¿Cuál es la diferencia entre el formato JSON y la validación?

El formateo reescribe el documento con una sangría consistente preservando su contenido y estructura. La validación solo analiza el documento e informa si es sintácticamente correcto, sin cambiar nada. Esta herramienta valida continuamente a medida que escribe y formatea según demanda.

¿Por qué JSON no permite comentarios?

La especificación de JSON define una gramática mínima de sólo datos; Los comentarios se excluyeron deliberadamente para mantener los analizadores simples y el formato sin ambigüedades. Las soluciones comunes son una clave "_comment" dedicada, JSON5 para humanos o YAML donde los comentarios son de primera clase.

¿Puede esta herramienta reparar JSON roto automáticamente?

Valida e informa la posición del error con precisión, pero no adivinará la intención. Reparar significa decidir qué quiso decir el autor: eliminar una coma final es seguro, pero elegir entre dos posibles comillas para una cadena no cerrada no es un juicio que una herramienta deba hacer en silencio.

¿El formato cambia mis datos?

No. El formateo solo ajusta los espacios en blanco entre los tokens. El orden de las claves, los valores y la estructura se conservan exactamente; la salida se vuelve a analizar con los mismos datos que la entrada.