JSON
JSON Path Extractor / Flatten
Aplanar (Flatten) un JSON anidado en una lista plana de "ruta: valor" y volver a ensamblarlo en una estructura anidada (Unflatten). La notación de ruta es la misma que en JSONPath/JSON Diff: store.book[0].price.
Deeply nested JSON is hard to compare or iterate over programmatically. Flatten unrolls such a structure into a flat list of "path: value" pairs (e.g. store.book[0].price: 12.99), and Unflatten rebuilds it.
How to use it
- Flatten: paste nested JSON and get a flat list of every leaf value with its full path.
- Unflatten: paste a list of "path: value" pairs to rebuild a nested JSON structure from it.
- The path notation matches this site's JSONPath and JSON Diff tools — items[0].name for array elements.
Common uses
- Turning a deeply nested API response into a flat list for import into a spreadsheet or analytics system.
- Building a translation dictionary or config back into nested JSON from flat keys (form.errors.email).
- Quickly finding every value on a given topic in a very large JSON document via a flat path list.
Things to keep in mind
Array index notation varies between libraries — this tool uses items[0], though some write items.0 without brackets.
Unflatten requires that paths don't conflict with each other (e.g. one and one.two at the same time) — otherwise the structure can't be unambiguously rebuilt.
Artículo sobre esta herramienta: JSON Flatten: convertir una estructura anidada en una lista plana
Preguntas frecuentes
¿Cómo se representan los elementos de un array en la ruta plana?
Se convierten en claves numeradas dentro de la ruta, como store.book[0].price, donde el número entre corchetes indica el índice del elemento en el array.
¿Se puede deshacer el aplanado y volver a la estructura original?
Sí, el modo Unflatten reconstruye el JSON anidado a partir de una lista "ruta: valor", usando la misma notación de ruta que en Flatten.
¿Se procesa el JSON en algún servidor externo?
No, tanto aplanar como reconstruir ocurren íntegramente en el navegador mediante JavaScript, sin enviar datos a ningún servidor.
¿Qué ocurre si una clave real contiene un punto?
Es una situación ambigua: la ruta user.name puede significar tanto un objeto anidado {"user": {"name": ...}} como una clave plana {"user.name": ...}. La notación de puntos no distingue entre ambos casos, así que conviene evitar esas claves o tratarlas por separado.
¿El formato de las rutas es igual en todas las herramientas parecidas?
No. La notación de puntos para objetos (user.name) es prácticamente universal, pero la notación de los índices de array varía: aquí se usa items[0], mientras que otras bibliotecas escriben items.0 sin corchetes.