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

Parse YAML in JavaScript with yaml

parse() is the simplest way to read YAML: it works like JSON.parse, but takes YAML text and returns plain JavaScript values.

All yaml examples yaml: usage and stats

Parse YAML in JavaScript with yaml: 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 parse. parse is a named export of the package. The docs describe it as the YAML counterpart of JSON.parse. [1]
  2. Read typed values. The code parses a small config and prints each field with its JavaScript type. Mappings become objects, sequences become arrays, and scalars become numbers, booleans, strings or null. [1]
  3. Flow sequences. The last line parses an inline [ ... ] sequence, the same input the README shows, where maybe stays a string. [2]

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 { parse } from 'yaml'

const src = `
app: demo
port: 8080
debug: false
tags: [api, web]
owner:
  name: Ada
  team: platform
ratio: 3.14159
nothing: null
`

const data = parse(src)

console.log('app:', data.app)
console.log('port:', data.port, '(' + typeof data.port + ')')
console.log('port + 1:', data.port + 1)
console.log('debug:', data.debug, '(' + typeof data.debug + ')')
console.log('tags:', JSON.stringify(data.tags), Array.isArray(data.tags) ? '(array)' : '')
console.log('owner.name:', data.owner.name)
console.log('owner.team:', data.owner.team)
console.log('ratio:', data.ratio)
console.log('nothing:', data.nothing)
console.log('flow sequence:', JSON.stringify(parse('[ true, false, maybe, null, 3.14159 ]')))
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, or change port to a quoted string to see its type change. Code written by AgentGid [1].

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

More yaml examples

Convert an object to YAML with yaml Parse options and schemas in yaml Multi-document YAML with yaml Edit YAML without losing comments

Sources

  1. yaml website
  2. 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 yaml? Ask AgentGid →