Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 3 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

Parse YAML with js-yaml load()

load() reads YAML text and returns JavaScript data, which is the usual first step when an app reads a YAML config file.

All js-yaml examples js-yaml: usage and stats

Parse YAML with js-yaml load(): screenshot of the example below running
The code below, running in Chromium on our server (Oct 12, 2026). Press Run to see it live and change it.

How it works

  1. Import load. The README imports load as a named export from js-yaml, which this example does as well. [1]
  2. Read the result. The returned value is plain data. The code reads a string, a number, a boolean, a nested mapping and a list from it and prints them. [1]

Run and edit it

It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.

import { load } from 'js-yaml'

const text = `
greeting: hello
version: 3
enabled: true
server:
  host: localhost
  port: 8080
languages:
  - en
  - de
  - ja
`

try {
  const document = load(text)
  console.log('greeting:', document.greeting)
  console.log('version:', document.version, '(' + typeof document.version + ')')
  console.log('enabled:', document.enabled, '(' + typeof document.enabled + ')')
  console.log('server.host:', document.server.host)
  console.log('server.port:', document.server.port)
  console.log('languages:', document.languages.join(', '))
  console.log('language count:', document.languages.length)
  console.log('as JSON:', JSON.stringify(document))
} catch (e) {
  console.log('error:', e.message)
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Add a new key to the YAML text and print it with another console.log line. Code written by AgentGid [1].

Checked Oct 12, 2026: it starts without errors in Chromium with js-yaml 5.4.3. Needs WebGL.

More js-yaml examples

Write YAML with js-yaml dump() Handle YAML parse errors in js-yaml Update a YAML config with js-yaml

Sources

  1. js-yaml README (GitHub)

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with js-yaml? Ask AgentGid →