JSON Sorter - Key/Value

A simple, fast and free online tool to sort flat JSON objects by keys or values

Input JSON

Configuration Options

Sort Options

Sort the JSON object by keys

Sort the JSON object by values instead of keys

If unchecked, sort in descending order

Value Type Handling

If checked, non-primitive values (objects, arrays) are added at the end

Note: Only applicable when sorting by value

Output JSON

How to Use

  1. Enter or paste your flat JSON object in the input field on the left.
  2. Configure the sorting options based on your needs:
    • Sort by key: Sort the JSON object by keys (default)
    • Sort by value: Sort the JSON object by values instead of keys
    • Ascending order: Choose ascending (A-Z, 0-9) or descending (Z-A, 9-0) order
    • Allow non-primitives: Handle objects and arrays in values
  3. Click the "Sort JSON" button to process your JSON.
  4. The result will appear in the output field on the right.
  5. Use "Copy to Clipboard" or "Download JSON" to save your result.

Examples

Sort by Key (Ascending)

Input:

{"zebra": 1, "apple": 2, "banana": 3}

Output:

{"apple": 2, "banana": 3, "zebra": 1}

Sort by Value (Ascending)

Input:

{"a": 30, "b": 10, "c": 20}

Output:

{"b": 10, "c": 20, "a": 30}

Sort by Key (Descending)

Input:

{"apple": 1, "banana": 2, "cherry": 3}

Output:

{"cherry": 3, "banana": 2, "apple": 1}

Mixed Data Types

Input:

{"name": "John", "age": 30, "active": true}

Output (by key):

{"active": true, "age": 30, "name": "John"}

About JSON Sorter

This tool sorts flat JSON objects by their keys or values, making it easy to organize and transform JSON data for various use cases. It's particularly useful for:

The tool includes robust error handling and configuration options to handle edge cases like non-primitive values, different data types, and invalid JSON structures. You can choose to sort by keys or values, in ascending or descending order.

Related Tools