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.

