JSON Flatten

Flatten deeply nested JSON into a single-level object with dot-notation keys — great for CSV export and database storage.

About JSON Flattening

JSON flattening transforms a deeply nested JSON object into a flat single-level object where nested keys are combined using a separator (commonly a dot). For example, {"user":{"name":"Alice","address":{"city":"NYC"}}} becomes {"user.name":"Alice","user.address.city":"NYC"}.

This transformation is extremely useful when exporting JSON to CSV format (since CSV doesn't support nesting), storing JSON data in SQL databases with flat column schemas, comparing flattened JSON structures for equality, and working with systems that expect flat key-value formats like environment variables or AWS SSM parameters.

Arrays are flattened using numeric indices — e.g., {"items":[{"id":1},{"id":2}]} becomes {"items.0.id":1,"items.1.id":2}. This preserves all data while removing structural nesting.

FAQ

What separator should I use?
Dot notation (.) is the most common and is used by MongoDB, JSONPath, and most documentation. Underscore (_) is useful when the flattened keys will be used as environment variable names (which can't contain dots). Slash (/) follows the JSON Pointer (RFC 6901) convention.
Can I unflatten the result?
Yes — use the JSON Unflatten tool to reconstruct the original nested structure from flattened dot-notation keys.