Skip to content
Tezmy Tools

XML Minifier

Remove comments and extra whitespace from XML to make it smaller

107 → 78 characters (27% smaller).

Runs in your browser. Nothing is uploaded.

About the XML Minifier

Readable XML is full of indentation and line breaks that a program does not need. Minifying removes the whitespace between tags and, if you wish, the comments, so the same document takes less space. Paste your XML and the compact version appears with a count of how much was saved. Text inside elements, attributes and CDATA sections are kept as they are, and the declaration at the top stays. The tool checks that the input looks like XML before it starts. It runs in your browser, so your files are not uploaded.

Updated October 2026

How to use the XML Minifier

  1. 1Paste your XML into the box.
  2. 2Decide whether to keep comments; by default they are removed.
  3. 3Read the minified XML on the right.
  4. 4Check the saving shown below the box.
  5. 5Copy the result or download it as an .xml file.

Why minify XML

XML is verbose. Opening and closing tags repeat every name, and indentation adds more. In a large feed, a sitemap or a configuration file, the whitespace can be a noticeable share of the size. Removing it speeds up transfers and lowers storage a little.

Minified XML is also a handy single-line form for pasting into a field, a message or a test.

    What is kept and what is removed

    The tool removes comments (unless you keep them), the whitespace between tags and spaces before the end of a tag. It keeps the text inside elements, attribute values, processing instructions such as the XML declaration and everything inside CDATA. It does not rename anything or reorder anything.

    • Removed: indentation and line breaks between tags
    • Removed: comments (optional)
    • Kept: attributes, text, CDATA, declaration

    Related jobs

    To make compact XML readable again, use the XML Formatter. To turn XML into JSON, CSV or YAML, use the converters on this site. For XML sitemaps, the XML Sitemap Generator creates a valid file.

      Common uses

      Developers minify XML before embedding it in a request body, a message queue or a test fixture. Site owners minify a large sitemap or product feed before uploading it. Teams minify configuration that is stored in a single database field. In each case the readable copy stays in version control and only the compact copy travels.

      Because the tool works on the text, namespaces, prefixes and the order of attributes are left exactly as written.

        A few cautions

        If an element holds text where spaces matter, such as preformatted code or a poem with deliberate line breaks, wrap it in CDATA before minifying, because whitespace between words inside plain text is trimmed only at the edges of tags.

        Check the output against the original with a diff tool if the file is important. The input must look like XML, which means it starts with an XML declaration or an opening tag, otherwise the tool shows a message instead of guessing. For JSON use the JSON Minifier, and XML to JSON Converter moves the data across.

          Features

          • Removes whitespace between tags
          • Removes comments, or keeps them if you wish
          • Keeps text, attributes and CDATA
          • Shows characters saved
          • Copy or download
          • Private: nothing is uploaded

          Frequently asked questions

          How do I minify XML?

          Paste the XML into the box. The tool removes indentation, line breaks between tags and comments, and shows the compact result. Copy it where you need it.

          Does minifying XML change the data?

          The elements, attributes and text stay the same. Only formatting whitespace between tags and comments are removed. Programs that read the XML see the same content.

          Are CDATA sections preserved?

          Yes. Text inside a CDATA section is kept exactly as written, including its spaces and line breaks.

          Can I keep the comments?

          Yes. Tick Keep comments and they remain in the output. Leave it off to remove them, which usually saves the most space.

          When should I not minify XML?

          When people need to read or edit the file, or when whitespace inside text is meaningful, as in some mixed-content documents. Keep a formatted copy for editing and minify only the version you send.

          Is the XML uploaded?

          No. The XML is processed in your browser and stays on your device.

          Related tools