Input YAML
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 YAML
How to Use
- Enter or paste your flat YAML 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 YAML.
- The result will appear in the output field on the right.
- Use "Copy to Clipboard" or "Download YAML" to save your result.
Examples & Info
Basic Example
Input:
firstName: John lastName: Doe age: 30
Output:
John: firstName Doe: lastName '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 YAML
- • 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
- • YAML to YAML transformations
About YAML Key-Value Swapper
This tool swaps the keys and values in a flat YAML object, creating a reverse mapping. It's particularly useful for:
- Creating reverse lookup tables from existing YAML mappings
- Transforming YAML configuration files
- Converting data structures for different API requirements
- Inverting simple dictionaries and mappings in YAML format
- Data preprocessing for analytics and reporting
- YAML-based configuration management
The tool includes robust error handling and configuration options to handle edge cases like duplicate values, non-primitive types, and invalid YAML structures. Output is generated in standard block style YAML format.