Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Convert XML to YAML

Convert XML data to YAML format. Preserves structure, attributes, and text content. 100% client-side.

Your files never leave your browser
XML Input0 chars, 0 lines
YAML Output0 chars, 0 lines
Error:
    Ready·

    Paste your XML, get valid YAML back — with nested elements, attributes, and repeated tags all mapped correctly. No fiddling with indentation by hand or guessing how arrays should look.

    It parses the full DOM tree, turns sibling elements into YAML sequences, and prefixes attributes with "@" so nothing collides. And everything runs in your browser. Nothing gets uploaded.

    How It Works

    Paste XML
    ➔
    Parse DOM Tree
    ➔
    Output YAML

    The browser's built-in XML parser reads your document into a DOM tree. Each element becomes a YAML key, child elements become nested objects, and repeated tags get grouped into arrays automatically. Attributes show up with an "@" prefix so they don't clash with child element names.

    Examples

    Simple Config File

    A basic app configuration with a few settings — the kind you'd find in a Spring Boot or .NET project.

    INPUT
    <config> <database> <host>localhost</host> <port>5432</port> <name>myapp_db</name> </database> </config>
    OUTPUT
    config: database: host: localhost port: "5432" name: myapp_db

    XML with Attributes

    Attributes get an "@" prefix in YAML so they stay separate from child elements. This is how a book catalog with ISBN attributes converts.

    INPUT
    <catalog> <book isbn="978-0-13-468599-1"> <title>The Pragmatic Programmer</title> <price>49.99</price> </book> </catalog>
    OUTPUT
    catalog: book: "@isbn": "978-0-13-468599-1" title: The Pragmatic Programmer price: "49.99"

    Repeated Elements Become Arrays

    When multiple sibling elements share the same tag name, the converter groups them into a YAML sequence. Common in API responses and data feeds.

    INPUT
    <users> <user> <name>Alice</name> <role>admin</role> </user> <user> <name>Bob</name> <role>editor</role> </user> </users>
    OUTPUT
    users: user: - name: Alice role: admin - name: Bob role: editor

    Who Uses This

    💻 Backend Developers

    Migrating legacy XML configs to YAML for Kubernetes, Docker Compose, or CI/CD pipelines.

    ⚙️ DevOps Engineers

    Converting Maven POM files or Ant build scripts into YAML-based workflows.

    📊 Data Analysts

    Turning XML data exports into YAML for easier reading and quick edits in a text editor.

    🎓 Students

    Learning how XML structures map to YAML by seeing side-by-side conversions in real time.

    Common Mistakes

    Pasting invalid XML

    Missing a closing tag or having mismatched brackets will throw a parse error. Run your XML through a validator first if you're not sure it is well-formed.

    Forgetting about namespace prefixes

    XML namespaces like <soap:Envelope> will carry the prefix into your YAML keys. Strip them from the source XML beforehand if you don't want "soap:Envelope" as a key name.

    Expecting numbers to stay unquoted

    XML treats everything as text. So <port>5432</port> becomes port: "5432" in the output. That's correct behavior — you can remove the quotes manually if your YAML parser needs a raw integer.

    Technical Details

    Frequently Asked Questions

    How does the converter handle XML attributes?

    Attributes get an "@" prefix in the YAML output. So <book id="1"> becomes @id: "1" nested under the book key. There is a toggle in the toolbar if you want to skip attributes entirely.

    Can I convert YAML back to XML?

    This tool goes one direction — XML to YAML. For the reverse, check our YAML to XML converter. Round-tripping works best when you haven't manually edited the YAML structure after conversion.

    What happens with XML CDATA sections?

    CDATA content is treated as plain text. The CDATA wrapper gets stripped and the raw text inside becomes the YAML value for that element. No special markers are added.

    Is my XML data safe? Does it get stored anywhere?

    Completely safe. The conversion runs entirely in your browser using JavaScript. Nothing gets sent to a server, nothing is logged, and nothing is stored. Close the tab and it's gone.

    Why are all my numbers wrapped in quotes in the YAML output?

    XML doesn't have data types — everything is a string. The converter preserves that by quoting numeric values. If you need unquoted numbers for your YAML parser, you'll need to remove the quotes manually or run a post-processing step.

    Share: