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 options and schemas in yaml

The same YAML text can mean different things depending on the schema and YAML version, and parse options let you choose which rules apply.

All yaml examples yaml: usage and stats

Parse options and schemas in 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. Integers as BigInt. With { intAsBigInt: true } the number 999 comes back as a bigint instead of a number. [1]
  2. Failsafe schema. { schema: 'failsafe' } keeps scalars as strings, so 999 is returned as the string '999'. [1]
  3. YAML 1.1 booleans and the json schema. By default No is a string. With version: '1.1' or schema: 'yaml-1.1' it becomes false, and the json schema rejects it, so the code catches the error. [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 { parse } from 'yaml'

const show = (label, value) =>
  console.log(label.padEnd(36), String(value), '(' + typeof value + ')')

// integers
show("parse('number: 999')", parse('number: 999').number)
show('intAsBigInt: true', parse('number: 999', { intAsBigInt: true }).number)
show("schema: 'failsafe'", parse('number: 999', { schema: 'failsafe' }).number)

// YAML 1.2 core schema vs YAML 1.1
show("parse('No')", parse('No'))
show("version: '1.1'", parse('No', { version: '1.1' }))
show("schema: 'yaml-1.1'", parse('No', { schema: 'yaml-1.1' }))
show("parse('3')", parse('3'))
show("parse('3', failsafe)", parse('3', { schema: 'failsafe' }))

// the json schema only accepts JSON-style scalars
try {
  parse('No', { schema: 'json' })
} catch (err) {
  console.log("schema: 'json' error:", err.message.split('\n')[0])
}
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.

Try other values such as 'yes', 'on' or '0o14' with and without version: '1.1'. 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

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

Sources

  1. yaml website

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 →