Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

PyYAML

Read and write settings files in Python.

UtilitiesPYPI

GitHubWebsite

1. License

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”

MIT allows use in paid and closed-source products.

github.com/yaml/pyyaml/blob/main/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What PyYAML does

PyYAML is a free Python library that reads and writes YAML, the plain-text format many settings files use. Your app turns such a file into ordinary Python data and can save data back the same way. It does not keep comments when it rewrites a file, and it reads a few words like "no" and "off" as false.

What people build with it

Read your app's settings file

Shop name, languages and limits live in one readable file; your app loads them at start instead of hard-coding them.

Save data as a readable file

Your app writes its settings or an export so a person can open and edit it in any text editor.

Open files people upload

Users upload a settings or data file; your app reads only plain data from it and never runs code hidden inside.

Read multi-part deployment files

One file holds several blocks split by --- lines, as server setup files often do; your script reads each block in turn.

Edit blog post headers Idea

Markdown posts start with a short settings block (title, date, draft); a script flips draft to false before publishing.

PyYAML popularity

76 / 100
Gid Score, #180 overall
322M
downloads a week, pypi
2,985
GitHub stars
371
agent projects use it
PyYAML: downloads per weekPyPI, pyyaml 315,333,418
PyYAML: GitHub starsyaml/pyyaml 2,985

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How PyYAML is used

  • PyYAML is a dependency in 371 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (22.9% of the 1,623 Python ones), #3 of 408 in utilities.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,578; those are left out of every share on this page.
  • Projects that use it most often also use Pydantic (49.3%), python-dotenv (44.7%), Requests (41.2%).
  • It is more common in projects set up for OpenClaw (12.9%) than for OpenAI Codex (4.7%).

By coding agent

216 projects, 6.6%
159 projects, 5.2%
139 projects, 5.7%
43 projects, 12.9%
30 projects, 6.3%
22 projects, 4.7%
17 projects, 6.1%
17 projects, 5.0%

Often used with

In 49.3% of its projects
In 44.7% of its projects
In 41.2% of its projects
In 39.1% of its projects
In 36.1% of its projects
In 34.8% of its projects
In 33.2% of its projects
In 25.6% of its projects

PyYAML in practice

Strengths

A C parser and emitter, one argument away

With the LibYAML bindings installed, you switch backends per call: <code>Loader=yaml.CLoader</code> for loading, <code>Dumper=yaml.CDumper</code> for dumping. The README calls these the "fast LibYAML-based parser and emitter".

Three install-time choices for the C bindings

Pass no flag and <code>setup.py</code> builds the bindings only if it finds LibYAML. <code>--with-libyaml</code> skips the check and forces the build. <code>--without-libyaml</code> skips the check and the build.

Both backends tested, local LibYAML build pinned

<code>make test</code> runs the pure Python tests, builds a local LibYAML, then runs the extension tests. The local LibYAML build is pinned by <code>LIBYAML-REF</code>, which defaults to <code>0.2.5</code>. <code>make test-python</code> and <code>make test-libyaml</code> run one mode each.

PyYAML releases listed from 3.01 (2006-05-07)

The website's news list covers PyYAML, LibYAML and PySyck. Its PyYAML entries start with 3.01 on 2006-05-07. It records Python 3 support arriving in 3.08, released on 2008-12-31.

Watch out for

The fast path is opt-in twice

The bindings have to be built at install time. Even then, the README's examples request the C classes explicitly on each <code>load</code> and <code>dump</code> call.

Free-threading support is experimental

Release 6.0.3 adds support for Python 3.14. Its free-threading support is marked experimental.

Website and README list different chat channels

pyyaml.org lists development chat on <code>irc.freenode.net</code>. The README sends you to Matrix or <code>irc.libera.chat</code>. The website's news list ends at 2020-06-01.

C loader and dumper, and loading untrusted input

>>> yaml.load(stream, Loader=yaml.CLoader)
>>> yaml.dump(data, Dumper=yaml.CDumper)
>>> yaml.safe_load(stream)

More about PyYAML

Packages around it
  • pydantic: Data validation
  • python-dotenv: .env file loading
  • requests: HTTP client
  • numpy: Numeric arrays
  • uvicorn: ASGI server
  • fastapi: Web API framework
More in Utilities

Alternatives

PyYAML This page

MITGid 76322M/wk

ruamel.yaml

Pick ruamel.yaml when you edit files people maintain by hand; it keeps comments, key order and formatting on a round trip.

js-yaml

Pick js-yaml when the code that reads the file is JavaScript or Node.js rather than Python.

yaml

Pick the yaml package for JavaScript when you need full spec compliance and to keep comments in JavaScript code.

Compare PyYAML with another tool

Get started

Tell your AI assistant

“Use the Python library PyYAML (pin pyyaml==6.0.3, import yaml) to read config.yaml with yaml.safe_load, quote values like NO, off and 1.10 that must stay text, and write changes with yaml.safe_dump(sort_keys=False, allow_unicode=True).”

  1. Install PyYAML into your project's Python environment. Note: the package is named PyYAML, but you import yaml.

    pip install pyyaml
    

    From pyyaml.org/wiki/PyYAMLDocumentation

  2. Read files you did not write yourself with safe_load, never plain load.

    yaml.safe_load(stream)
    

    From github.com/yaml/pyyaml/blob/main/README.md

  3. Write data back with safe_dump; pass sort_keys=False to keep your key order.

    From pyyaml.org/wiki/PyYAMLDocumentation

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## PyYAML
- For any YAML stream you don't trust, use `yaml.safe_load(stream)`, as the README instructs.
- Only pass `Loader=yaml.CLoader` / `Dumper=yaml.CDumper` when the LibYAML bindings are installed.
- To control the C build from source, use `python setup.py --with-libyaml install` (force) or `python setup.py --without-libyaml install` (skip).
- When changing PyYAML itself, run `make test` to cover both backends. Use `make test-python` or `make test-libyaml` for one mode.
- To test against a specific interpreter, set it explicitly, e.g. `make test PYTHON-VERSION=3.13.5`.
- Treat free-threading support on Python 3.14 as experimental (added in 6.0.3).

Mistakes to avoid

yaml.load(text)
yaml.safe_load(text)

Since 6.0 load() without Loader= raises TypeError (our run), and load with the full loader is unsafe for untrusted input.

country: NO / debug: off / version: 1.10 left unquoted
country: 'NO' / version: '1.10' in the file, or set the values as strings before safe_dump

Our run read NO and off as False and 1.10 as the number 1.1.

yaml.safe_dump(data) and expecting the original key order and non-English text as written
yaml.safe_dump(data, sort_keys=False, allow_unicode=True)

In our run the defaults sorted keys alphabetically and wrote Cyrillic text as \u escape codes.

Load, change and save a hand-edited config with PyYAML
Use ruamel.yaml for round trips where comments must survive

In our run the comment lines of config.yaml were gone after safe_dump.

pip install yaml
pip install pyyaml (then import yaml)

The package on PyPI is PyYAML; the import name is yaml.

Questions

Can I use it in a paid, closed-source app?

Yes. It is MIT-licensed; keep the copyright and license notice with its files.

Why does yaml.load(text) fail with "missing 1 required positional argument: 'Loader'"?

Since version 6.0 load needs a Loader. Use yaml.safe_load(text) instead (our run showed this TypeError).

Is FullLoader or full_load safe for untrusted files?

The project's own page says to avoid it for untrusted data; use safe_load.

Why did my value "NO" become False?

PyYAML reads on, off, yes, no and similar words as true or false. Put such values in quotes in the file.

Is there a faster mode?

Yes. When the LibYAML C parser is present, CLoader and CDumper are much faster; the PyPI wheels in our run had it built in.