Input JSON
Configuration Options
Duplicate Value Handling
Value Type Handling
If unchecked, non-primitive values will cause an error
Ensures all new keys are valid strings
Output JSON
How to Use
- Enter or paste your flat JSON object in the input field on the left.
- Configure the options based on your needs:
- Duplicate handling: Choose how to handle multiple keys with the same value
- Value types: Configure how to handle non-primitive values
- Click the "Swap Keys & Values" button to process your JSON.
- The result will appear in the output field on the right.
- Use "Copy to Clipboard" or "Download JSON" to save your result.
Examples & Info
Basic Example
Input:
{"name": "John", "age": "30"}
Output:
{"John": "name", "30": "age"}
Duplicate Values (Group Mode)
Input:
{"a": "1", "b": "1", "c": "2"}
Output:
{"1": ["a", "b"], "2": "c"}
Validation Rules
- • Input must be valid JSON
- • Input must be an object (not array or primitive)
- • Values become keys, so they must be valid
- • Null values are skipped
- • Boolean/number values are converted to strings
Use Cases
- • Reverse lookup tables
- • Configuration file transformations
- • Data structure inversions
- • API response transformations
About JSON Key-Value Swapper
This tool swaps the keys and values in a flat JSON object, creating a reverse mapping. It's particularly useful for:
- Creating reverse lookup tables from existing mappings
- Transforming configuration files
- Converting data structures for different API requirements
- Inverting simple dictionaries and mappings
- Data preprocessing for analytics and reporting
The tool includes robust error handling and configuration options to handle edge cases like duplicate values, non-primitive types, and invalid JSON structures.