Flatten an XML

Flatten an XML into key-value pairs with live preview. Convert nested XML into plain or JSON format, with options for dot notation and attributes.

Paste your input above or import a file below.
No file chosen
Supported file types: .xml, .txt, .html, .htm
Total keys: 0
Options
Include attributes
Use dot notation
Maximize output
Output Format:

How to Use:

  • Paste your XML or click Choose File to upload .xml, .txt, or .html
  • Toggle Include attributes to extract and flatten XML attributes alongside elements
  • Turn on Use dot notation to separate nested keys with . instead of _
  • Switch Output Format between:
    • JSON: outputs structured JSON
    • Plain text: displays flattened keys as key: value
  • Enable Maximize output to expand the output display
  • Output updates automatically as you edit or toggle settings
  • Click Copy Output to copy the flattened result
  • Use Export to File to save as a .txt
  • Press Clear All to reset the tool

What Flatten an XML can do:

Flatten an XML helps you convert nested XML into a simple list of keys and values. It’s great when you need to debug complex structures, transform XML for systems that don’t support nesting, or prepare data for tools like spreadsheets or JSON processors. You can preserve attributes, adjust the key style with dot notation, and choose between JSON and flat text outputs. All updates happen instantly in your browser.

Example:

Input XML:

<note id="123">
<to>Tove</to>
<details>
<priority>high</priority>
</details>
</note>

Flattened Output (dot notation):

note.@id: 123  
note.to: Tove
note.details.priority: high

As JSON:

{
"note.@id": "123",
"note.to": "Tove",
"note.details.priority": "high"
}

Common Use Cases:

Use Flatten an XML when converting XML to flat formats for CSV or logs, debugging nested data, extracting fields for automation, or simplifying config files. It’s especially useful for QA engineers, developers, and data analysts working with systems that expect flat key-value input.

Useful Tools & Suggestions:

Once you’ve flattened your XML, try Convert XML to CSV it’s much easier when the nesting is gone. And if you’re checking structure before or after, Find XML Nesting Depth helps you see how deep things were.