YAML to JavaScript Converter
Paste YAML and get a JavaScript object literal — pick const, ES module export, CommonJS, IIFE, or bare expression style, and control quoting, indentation, and variable name.
Last updated: May 27, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is YAML to JavaScript Converter?
YAML configuration files are common in Node.js and browser tooling (Vite, Vitest, ESBuild configs started as YAML; many CI files are YAML). Sometimes you need to embed that configuration directly as a JavaScript object — for a mock, a fixture, or a hand-rolled config loader.
This tool parses YAML to a JSON value internally and then emits a JavaScript object literal with idiomatic key quoting (bare identifiers where valid, quoted strings otherwise). Choose between five output styles to match your project's module system.
How to Use YAML to JavaScript Converter
Paste YAML into the input panel.
Choose an output style: const, ES module, CommonJS, IIFE, or expression.
Set the variable name, quote style, indent, and semicolon preference.
Copy the JavaScript output.
Common Use Cases
- Embedding a YAML config as a JavaScript constant for a test fixture.
- Converting a Kubernetes or CI YAML file to a typed JS object for tooling.
- Generating a JS module export from a YAML data file.
- Creating a seed file from a YAML data definition.
Example Input and Output
A YAML mapping converts to a JavaScript const object literal.
host: localhost
port: 8080
debug: trueconst data = {
host: 'localhost',
port: 8080,
debug: true,
};Privacy
All YAML parsing and JavaScript generation happen in your browser. No content is sent to a server.
YAML coverage
The internal YAML parser handles the common subset: mappings, sequences, scalars, and multi-line strings. Anchors, aliases, and YAML tags are not supported.
Frequently Asked Questions
How is this different from YAML to JSON?
JSON output uses double-quoted strings everywhere and strict JSON syntax. The JS output uses unquoted identifier keys, optional single quotes, and your choice of module wrapping.
When should I use the IIFE style?
Use IIFE when you want an immediately-invoked function expression that returns the value — useful for browser globals or older script environments without module support.
Does this send my YAML anywhere?
No. All parsing and conversion happen locally in your browser.
Related Tools
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML — for config files, CI pipelines, and Kubernetes manifests.
YAML to TypeScript Converter
Generate TypeScript interfaces from a YAML example. Parses YAML to JSON internally, then emits typed interfaces with nested types and array element inference.
YAML to Python Converter
Generate Python classes from a YAML example. Pick @dataclass, pydantic, TypedDict, or attrs style. Targets Python 3.10+ or 3.9 type syntax.
JSON to JavaScript Converter
Convert JSON to a JavaScript object literal — bare expression, const variable, ES module, CommonJS export, or IIFE. Unquoted identifier keys when valid, single or double quoted strings.
YAML Validator
Validate YAML syntax online. Shows valid/invalid status with exact error line and column, plus structure stats for valid documents.
YAML Beautifier
Format and prettify YAML with configurable indentation and optional key sorting. Validates YAML syntax instantly.

