Loading...
Your adventure is about to begin
Transform nested JSON objects into flat key-value structures and vice versa with our free online JSON flatten/unflatten tool. Convert complex nested data to single-level objects for CSV export, database storage, or configuration management. Supports custom delimiters (dot, underscore, slash), bracket or dot array notation, and preserve arrays option. Perfect for data migration, search indexing, Excel export, and simplifying complex API responses. Unflatten flattened JSON back to original nested structure instantly. 100% browser-based with no data upload.
Loading...
Your adventure is about to begin
See how nested JSON transforms into a flat structure and back again. This example shows both directions of the conversion process.
{
"user": {
"name": "John Doe",
"email": "john@example.com",
"address": {
"street": "123 Main St",
"city": "New York"
},
"hobbies": ["reading", "coding"]
}
}
{
"user.name": "John Doe",
"user.email": "john@example.com",
"user.address.street": "123 Main St",
"user.address.city": "New York",
"user.hobbies[0]": "reading",
"user.hobbies[1]": "coding"
}
Convert complex API responses to flat CSV/Excel formats for business analysts. Each nested path becomes a spreadsheet column, making it easy to import into Excel, Google Sheets, or data analysis tools.
Store complex JSON in flat database schemas or key-value stores like Redis. Flattened structure maps perfectly to database columns or cache keys, simplifying queries and improving performance.
Create searchable indices where each path is individually queryable. Flattened JSON makes it easy to build search engines, auto-complete features, and filtering systems that need to access deeply nested values.
Manage application settings as flat key-value pairs that are easier to override, version control, and deploy. Environment variables and config files work better with flat structures.
Prepare JSON data for machine learning pipelines that require flat feature vectors. Each flattened key becomes a feature, and values become training data points.
Migrate data between systems with different schema requirements. Flatten to transform, manipulate, then unflatten to restore structure in the target system's format.
Select "Flatten" to convert nested JSON to flat structure, or "Unflatten" to restore nested structure from flat JSON.
Set your preferred delimiter (default: dot), choose array notation (bracket [0] or dot .0), and optionally preserve arrays when flattening.
Paste your JSON or upload a .json file. Use the example buttons to see how flattening works with sample data.
Click the "Flatten" or "Unflatten" button to transform your JSON. Copy the output or use "Swap & Reverse" to convert it back.
Choose from our suite of JSON tools to start processing your data right away.
Convert JSON arrays to CSV format for Excel and spreadsheet applications.
Transform JSON into Excel spreadsheets with automatic column detection.
Beautify and format JSON with syntax highlighting and customizable indentation.
Validate JSON syntax with AI-powered error detection and automatic fixing.
Edit JSON with tree view, real-time validation, and statistics.
Navigate and query JSON structures with JSONPath expressions.
JSON flattening is the process of converting a nested JSON object into a flat, single-level object where each key represents the complete path to a value. This is useful for data export to CSV/Excel, database storage in flat schemas, configuration management, search indexing, and simplifying data analysis. For example, {'user': {'name': 'John'}} becomes {'user.name': 'John'}.
Bracket notation represents array indices as [0], [1], etc. (e.g., 'hobbies[0]'), while dot notation uses dots like .0, .1 (e.g., 'hobbies.0'). Bracket notation is more common and compatible with JSONPath expressions, making it easier to query and unflatten. Dot notation can be simpler but may cause issues if your data contains numeric keys.
Yes! Our tool supports both flattening and unflattening. Simply switch to 'Unflatten' mode and paste your flattened JSON. The tool will reconstruct the nested object structure based on the delimiters and array notation. Make sure to use the same delimiter and array notation settings that were used during flattening for accurate results.
By default, arrays are flattened into individual key-value pairs with indices (e.g., 'items[0]', 'items[1]'). If you enable 'Preserve Arrays', arrays will remain intact as values rather than being expanded. This is useful when you want to keep array data together but still flatten the nested object structure around them.
You can use any custom delimiter (period, underscore, slash, etc.) by changing the delimiter setting. Common delimiters include '.' (dot), '_' (underscore), '/' (slash), and '-' (hyphen). Choose a delimiter that doesn't conflict with your data values. For example, if your JSON keys contain dots, use an underscore instead.
Absolutely! Flattened JSON is perfect for storing in relational databases or NoSQL databases that don't support nested structures well. Each flattened key becomes a column name, and the value becomes the cell data. This is especially useful for data warehouses, analytics platforms, and systems that require flat table structures.
Yes, our flattener handles unlimited nesting depth. It recursively traverses all levels of your JSON structure and creates complete paths for every value, no matter how deeply nested. For example, 'user.profile.settings.privacy.email' represents five levels of nesting in the flattened format.
Common use cases include: (1) Exporting complex API responses to Excel/CSV for business users, (2) Storing configuration files in flat key-value databases like Redis, (3) Creating search indices where each path is searchable, (4) Simplifying data for machine learning pipelines, (5) Migrating data between systems with different schema requirements, and (6) Debugging by viewing all data paths in one flat structure.