JSON Flatten & Unflatten Converter

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.

{
}

Initializing JSON Engine...

Preparing local environment

Understanding Flatten vs. Unflatten: A Practical Example

See how nested JSON transforms into a flat structure and back again. This example shows both directions of the conversion process.

Nested JSON (Original)

{
  "user": {
    "name": "John Doe",
    "email": "john@example.com",
    "address": {
      "street": "123 Main St",
      "city": "New York"
    },
    "hobbies": ["reading", "coding"]
  }
}

Flattened JSON

{
  "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"
}

Why Flatten and Unflatten JSON?

📊 Data Export & Analysis

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.

🗄️ Database Storage

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.

🔍 Search & Indexing

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.

⚙️ Configuration Management

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.

🤖 ML Data Preparation

Prepare JSON data for machine learning pipelines that require flat feature vectors. Each flattened key becomes a feature, and values become training data points.

🔄 Data Migration

Migrate data between systems with different schema requirements. Flatten to transform, manipulate, then unflatten to restore structure in the target system's format.

How to Use the JSON Flatten/Unflatten Tool
1

Choose Your Mode

Select "Flatten" to convert nested JSON to flat structure, or "Unflatten" to restore nested structure from flat JSON.

2

Configure Options

Set your preferred delimiter (default: dot), choose array notation (bracket [0] or dot .0), and optionally preserve arrays when flattening.

3

Input Your JSON

Paste your JSON or upload a .json file. Use the example buttons to see how flattening works with sample data.

4

Process & Copy Results

Click the "Flatten" or "Unflatten" button to transform your JSON. Copy the output or use "Swap & Reverse" to convert it back.

Ready to Get Started?

Choose from our suite of JSON tools to start processing your data right away.

Frequently Asked Questions
What is JSON flattening and why would I use it?

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'}.

What's the difference between bracket and dot array notation?

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.

Can I unflatten JSON back to its original nested structure?

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.

What happens to arrays when I flatten JSON?

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.

How do I handle custom delimiters?

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.

Can flattened JSON be used in databases?

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.

Will flattening work with deeply nested objects?

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.

What are common use cases for JSON flattening?

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.

- For a complete overview, see our full GuideJSON Flattening