Home › Developer Tools › XML to YAML Converter

XML to YAML Converter

Paste XML or open an .xml file and get tidy YAML instantly. Attributes become @keys, mixed text becomes #text, repeated tags become lists, and any well-formedness error is pointed out by line and column.

Last updated:

Parsed with your browser's own XML parser; nothing is uploaded. Drop an .xml file on the input. Tip: Ctrl + Enter converts.

Advertisement
Advertisement

How to use the XML to YAML Converter

  1. Paste your XML into the left box, drop an .xml file on it, or press Open .xml. A sample catalog is loaded to start.
  2. Choose the options: indentation, attribute prefix, text key and how repeated elements are listed.
  3. Read the YAML on the right. With Live update on it refreshes as you type.
  4. Fix any error: invalid XML shows the line and column; press Show in input to jump to it.
  5. Copy or download the result as a .yaml file.

How XML maps to YAML

XMLYAMLRule
<name>Ada</name>name: AdaText-only element becomes a key: value pair
<item id="7"/>item:
  "@id": 7
Attributes get the @ prefix
<price cur="USD">9.5</price>price:
  "@cur": USD
  "#text": 9.5
Text beside attributes goes under #text
<tag>a</tag><tag>b</tag>tag:
  - a
  - b
Repeated siblings become a list
<empty/>empty:Empty element is null
<![CDATA[a & b]]>a & bCDATA is read as plain text

Keys that start with @ or # are quoted in the YAML because those characters have a special meaning at the start of a plain YAML scalar.

Common XML errors

  • Mismatched tags: every <tag> needs a matching </tag> with the same case, or must be self-closed as <tag/>.
  • Unescaped ampersands: write &amp; instead of a bare &, or wrap the text in <![CDATA[ … ]]>.
  • More than one root element: an XML document has exactly one top-level element. Wrap several in a parent such as <items>.
  • Unquoted attributes: id=7 is HTML style; XML needs id="7".

Need JSON instead? Use the XML to JSON converter, or check the result with the YAML Validator.

Frequently asked questions

How are XML attributes converted to YAML?

Each attribute becomes a key that starts with the attribute prefix, "@" by default, so <price currency="USD"> gives "@currency: USD" under price. You can change the prefix (for example to "_" or nothing) or tick Ignore attributes to leave them out.

What is the #text key?

When an element has both attributes or child elements and its own text, the text cannot be the element's value on its own, so it is stored under the text key, "#text" by default. An element that only contains text is written as a simple key: value pair.

How are repeated elements handled?

Sibling elements with the same name are grouped into a YAML list in document order. A single element stays a plain mapping unless you choose Always a list, which makes every element a list so the structure is the same no matter how many items there are.

Are numbers and booleans converted?

With Detect numbers & booleans on, text such as 14, 189.99 or true is written without quotes so YAML reads it as a number or boolean. Values with leading zeros like 02134 stay strings. Turn the option off to keep every value as a string.

What happens to empty elements like <discontinued/>?

An empty element without attributes becomes a key with an empty (null) value, written as "discontinued:". If it has attributes, only the @attribute keys are written.

Why do some values have quotes?

YAML would misread certain plain strings, for example yes, no, on, off, null, values that look like numbers or dates, or text containing ": " or " #". These are quoted so the YAML means exactly what the XML said.

Is my XML uploaded?

No. The file is parsed by your browser's built-in XML parser and converted in this page, so nothing leaves your device.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

XML to JSONConvert XML to JSON with validation.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.XML FormatterBeautify, validate and minify XML with a collapsible tree view.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.JSON to Python ClassGenerate Python dataclasses, Pydantic models or TypedDicts with type hints from JSON.DOCX to Markdown ConverterConvert Word .docx to clean Markdown with headings, lists, tables, links and images in a ZIP.ES6 to ES5 ConverterTranspile modern JavaScript (ES2015+) to ES5 with Babel: targets, module format and loose mode.JavaScript Object to JSONTurn JS object literals and Python dicts into valid JSON: quotes keys, fixes commas and values.JSON Graph VisualizerSee JSON as an interactive node graph with zoom, collapse and search; export PNG or SVG.KML ViewerOpen KML and KMZ files on an interactive map: placemarks, paths, polygons, folders, export.MySQL to PostgreSQL ConverterConvert MySQL dumps and CREATE TABLE statements to PostgreSQL: types, AUTO_INCREMENT, ENUMs, quotes.Text to CSV ConverterTurn space-aligned, fixed-width, pipe or tab separated text into clean CSV with a live preview.VCF File ViewerOpen vCard .vcf files as contact cards with photos, search and duplicate check, export CSV.XML ViewerBrowse XML as a collapsible tree with search, XPath of any node, attributes and big-file support.JSON to C# ClassConvert JSON to C# classes or records with System.Text.Json or Newtonsoft attributes.JSON SorterSort JSON keys A-Z recursively, sort arrays by value or by a key, then pretty-print or minify.JSON to HTML TableConvert a JSON array of objects into clean HTML table code with CSS styles and a live preview.CSV to SQL ConverterConvert CSV to SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.IPv4 to IPv6 ConverterConvert IPv4 to IPv4-mapped, 6to4 and NAT64 IPv6, extract IPv4 from IPv6, and get int/hex/binary.cURL to Code ConverterConvert curl commands to JavaScript fetch, Axios, Python requests, Node.js, PHP and Go code.Code to ImageTurn code into a beautiful syntax-highlighted PNG with themes, window frame and background.Excel to JSON ConverterConvert Excel sheets (XLSX, XLS, ODS) to JSON with header row, type and shape options.CSV to Excel ConverterConvert CSV files to a real .xlsx workbook with typed numbers and dates, one sheet per file.CSV SplitterSplit a large CSV into smaller files by row count, file count or column value, header kept.CSV MergerCombine many CSV files into one, matching columns by name, with dedupe and a source column.VCF to CSV ConverterConvert vCard (.vcf) contacts to CSV for Google or Outlook, or turn a CSV back into a VCF.Calendar Event (.ics) GeneratorCreate an .ics calendar invite with time zone, reminders and repeats + Google/Outlook links.CSV Column ExtractorPick, reorder and rename CSV columns, filter rows by value, and export a new CSV or JSON.CSV Diff CheckerCompare two CSV files by key column and see added, removed and changed rows cell by cell.CSV Duplicate Row RemoverRemove duplicate rows from a CSV by all or selected columns and download the cleaned file.CSV to HTML TableTurn CSV into clean HTML table code with a live preview, styling options and one-click copy.CSV to Markdown TableConvert CSV to a neatly aligned GitHub Markdown table with column alignment and live preview.CSV TransposeSwap rows and columns of CSV, TSV or pasted spreadsheet data, with delimiter auto-detect.Date Format ConverterConvert any date to ISO 8601, RFC 2822, Unix time and custom strftime, moment or Java patterns.ENV to JSON ConverterConvert .env files to JSON or YAML and JSON back to .env, with quotes and multiline values.
See all 129 Data & File Format Converters →