Overview
Introduction
XML allows both single and double quotes around attribute values, but a document with a mix of both looks inconsistent.
This tool standardizes on double quotes.
What Is XML Double Quote Converter?
A quote-normalizing tool that re-serializes every attribute value using double quotes.
It re-escapes content correctly for the new delimiter.
How XML Double Quote Converter Works
The document is parsed and re-serialized.
Every attribute value is written between double quotes, with any literal double-quote characters inside the value escaped as "; single quotes inside the value are left as literal characters since they no longer need escaping.
When To Use XML Double Quote Converter
Use it to standardize quote style across a document assembled from multiple sources.
It's equally useful on a document that's been hand-edited inconsistently over time.
Often used alongside XML Single Quote Converter, XML Syntax Changer and XML Prettifier.
Features
Advantages
- Standardizes an entire document's attribute quoting in one pass.
- Correctly re-escapes content for the new quote character.
- Runs entirely client-side.
Limitations
- Only affects attribute-value quoting, not element structure or content.
- Re-indents the whole document as a side effect of re-serialization, matching this category's standard pretty-printing.
Examples
Best Practices & Notes
Best Practices
- Double quotes are the more common convention in hand-written and generated XML, prefer this over single quotes unless a specific tool requires otherwise.
- Run this before committing an XML file assembled by hand from multiple copy-pasted snippets.
- Use Use Single Quotes Everywhere instead if your target tooling specifically expects single quotes.
Developer Notes
Serialization logic lives in `normalize-xml-quotes.ts` and shares its structure with `toPrettyXml`, except the attribute-escaping function takes the target quote character as a parameter.
XML Double Quote Converter Use Cases
- Standardizing attribute quote style across a document assembled from multiple sources
- Cleaning up inconsistent quoting before a code review or commit
- Matching a linter or style guide that requires double-quoted XML attributes
Common Mistakes
- Expecting this to also reformat element structure, only attribute quoting changes.
- Assuming already-double-quoted attributes are left byte-for-byte identical, they're re-serialized (and thus re-indented) along with everything else.
Tips
- Use Use Single Quotes Everywhere for the opposite normalization.
- Check the FAQ above if the output doesn't look like what you expected.