Overview
Introduction
While double quotes are more common in XML, single quotes are equally valid and preferred by some tooling and style guides.
This tool standardizes a document to single quotes.
What Is XML Single Quote Converter?
The mirror image of Use Double Quotes Everywhere.
It's a quote-normalizing tool that re-serializes every attribute value using single quotes.
How XML Single Quote Converter Works
The document is parsed and re-serialized.
Every attribute value is written between single quotes, with any literal single-quote characters inside the value escaped as '; double quotes inside the value are left as literal characters.
When To Use XML Single Quote Converter
Use it to match a code generator, templating system, or style guide that expects single-quoted XML attributes.
It's also useful for standardizing quote style across a document assembled from multiple sources.
Often used alongside XML Double Quote Converter, XML Syntax Changer and XML Prettifier.
Features
Advantages
- Standardizes an entire document's attribute quoting in one pass.
- Runs entirely client-side.
- Correctly re-escapes content for the new quote character.
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
- Confirm your downstream tooling actually accepts single-quoted XML attributes before standardizing on this style, some strict consumers expect double quotes.
- Use Use Double Quotes Everywhere instead if you're not sure which convention your target system needs.
- Run the XML Validator after converting, to confirm the result is still well-formed.
Developer Notes
This shares its serialization logic with Use Double Quotes Everywhere (`normalize-xml-quotes.ts`), differing only in the quote character passed in.
XML Single Quote Converter Use Cases
- Matching a code generator or style guide that expects single-quoted attributes
- Standardizing quote style across a document assembled from multiple sources
- Preparing XML for a templating system that emits single-quoted attributes by convention
Common Mistakes
- Expecting this to also reformat element structure, only attribute quoting changes.
- Assuming double quotes are always the safer default, XML treats both as equally valid.
Tips
- Use Use Double Quotes Everywhere for the opposite normalization.
- Check the FAQ above if the output doesn't look like what you expected.