Overview
Introduction
YAML lets every string be written unquoted, single-quoted, or double-quoted, which is flexible but means a document assembled from several sources often ends up with an inconsistent mix of all three. This tool normalizes that: every string, key or value, comes out single-quoted.
Single quotes are a common style choice for teams that want visually lighter YAML and don't need double-quoted-only features like backslash escape sequences, since single-quoted strings are interpreted mostly literally.
What Is Change All Quotes to Single Quotes?
A YAML re-quoting tool that parses a document and re-serializes every string scalar, unquoted, double-quoted, or already single-quoted, uniformly as a single-quoted string.
It operates on the parsed value rather than the raw text, so it never mis-quotes a string or mishandles an edge case the way a text-based find/replace on quote characters could.
How Change All Quotes to Single Quotes Works
The input is parsed with a full YAML 1.2 parser. It's then re-serialized using the `yaml` package's `defaultStringType` and `defaultKeyType` stringify options set to `"QUOTE_SINGLE"`, which tells the stringifier to prefer single quotes for every string scalar it writes, both keys and values, rather than YAML's usual heuristic of using the most compact style that's unambiguous.
Non-string values (numbers, booleans, null) are unaffected, since they aren't strings to begin with; only values whose resolved type is `string` are subject to the quoting change.
When To Use Change All Quotes to Single Quotes
Use it to standardize quoting style across a config file assembled or edited by multiple people over time.
It's also useful when a team's style guide or linter specifically requires single-quoted strings in YAML.
Often used alongside Change All Quotes to Double Quotes, YAML Formatter & Prettifier and YAML Minifier.
Features
Advantages
- Correctly re-quotes every string via a real YAML stringifier, handling internal escaping (doubled single quotes) automatically.
- Applies consistently to both mapping keys and values, not just one or the other.
- Never changes a value's underlying type, only its quoting style.
- Runs entirely client-side, so configuration data never leaves your browser.
Limitations
- Comments are dropped, since the transformation parses and re-serializes the document, the same tradeoff as the YAML Formatter.
- Single-quoted YAML strings don't support backslash escape sequences (like `\n`); if a value legitimately needs one, it's represented literally rather than as an escape, which is standard YAML behavior for this style, not a bug in this tool.
- Only the first document in a multi-document (`---`-separated) YAML stream is processed.
Examples
Best Practices & Notes
Best Practices
- Agree on a quoting convention as a team before adopting this in a workflow, so future edits follow the same style rather than drifting again.
- Avoid single-quoting values that specifically rely on backslash escape sequences, since single-quoted YAML doesn't support them the way double-quoted YAML does.
- Use YAML Diff afterward to confirm only quoting changed, not any actual data.
Developer Notes
The conversion relies entirely on the `yaml` package's `defaultStringType`/`defaultKeyType: "QUOTE_SINGLE"` stringify options rather than any custom quoting logic, verified directly against the package's TypeScript definitions (`Scalar.Type`) to confirm the exact option name and accepted values before implementing. `defaultKeyType` is set explicitly even though it would fall back to `defaultStringType` by default, since being explicit here is clearer than relying on an implicit default.
Change All Quotes to Single Quotes Use Cases
- Standardizing quoting style across a YAML config maintained by multiple contributors
- Meeting a team style guide or linter rule that requires single-quoted YAML strings
- Normalizing YAML pulled from several different sources with inconsistent quoting before merging
- Preparing YAML for a downstream tool or template that expects consistently single-quoted strings
Common Mistakes
- Expecting numbers or booleans to get quoted too, they don't, since that would change their type.
- Forgetting that mapping keys are quoted along with values, if you only wanted values quoted, this tool's output will look more aggressive than expected.
- Single-quoting a value that relies on a backslash escape sequence and being surprised the escape is no longer interpreted, that's expected YAML single-quote behavior, not a conversion bug.
Tips
- Use YAML Diff before and after to confirm the only changes are quoting-related, not accidental data changes.
- If a value needs backslash escape sequences, double-quote it manually afterward rather than relying on single-quote style for that one value.
- Pair with YAML Formatter if you also want consistent indentation alongside consistent quoting.