PyYAML

A full-featured YAML parser and emitter for Python, with C-accelerated bindings

Library
PyPI
v6.0.3
2,958 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
61 /100 Good
Development Activity 44
Maintenance 24
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 82
Code Quality 78
Innovation 68
Learning Curve 85

PyYAML is the canonical YAML processing library for Python, providing a complete implementation of the YAML 1.1 specification for parsing YAML documents into native Python objects and serializing Python objects back into YAML text. It exposes a small, well-known API — yaml.safe_load, yaml.load, and yaml.dump — that has become the de facto standard for reading and writing configuration files, CI pipelines, Kubernetes manifests, and structured data across the Python ecosystem.

Under the hood, PyYAML is built as a layered pipeline of scanner, parser, composer, constructor, and resolver stages, each independently swappable, and it can optionally link against libyaml (via Cython bindings, CSafeLoader/CDumper) for significantly faster parsing and emitting on large documents. The library ships as pure Python by default so it works everywhere CPython runs, with the C extension as an opt-in performance upgrade.

What You Get

  • A complete YAML 1.1 parser and emitter accessible through yaml.safe_load(), yaml.load(), and yaml.dump()
  • Safe-by-default loading (SafeLoader/safe_load) that only constructs plain Python types, plus FullLoader and the legacy unsafe Loader for advanced tag resolution
  • Optional libyaml-backed CSafeLoader/CDumper classes for significantly faster parsing and emitting of large YAML documents
  • Support for custom YAML tags and Python-specific object serialization via representer/constructor registration
  • A layered, swappable pipeline (Reader, Scanner, Parser, Composer, Constructor, Resolver) that advanced users can extend or subclass

Common Use Cases

  • Loading and validating application configuration files written in YAML
  • Parsing CI/CD pipeline definitions (GitHub Actions, GitLab CI) and Kubernetes/Docker Compose manifests
  • Serializing Python data structures to human-readable YAML for storage or interchange
  • Round-tripping structured data between services or tools that standardize on YAML as their config format

Under The Hood

Architecture PyYAML is organized as a mixin-composed pipeline rather than a monolithic parser: Reader handles raw stream decoding, Scanner tokenizes the input, Parser turns tokens into a stream of parsing events, Composer assembles those events into a node graph, Constructor walks the node graph to build native Python objects, and Resolver decides implicit tag types (e.g. distinguishing a bare 42 as an int vs a string). Concrete loader classes such as SafeLoader, FullLoader, and Loader (in lib/yaml/loader.py) simply combine these mixins with different Constructor variants to control how much trust is placed in the input — SafeConstructor only ever builds plain dicts/lists/scalars, while Constructor/UnsafeConstructor can instantiate arbitrary Python objects from YAML tags, which is why yaml.load() requires an explicit Loader argument and safe_load() is the recommended default. The emitter side mirrors this with Emitter, Serializer, and Representer stages composed into Dumper/SafeDumper classes.

Tech Stack The library is pure Python at its core (lib/yaml/*.py, ~5,900 lines across scanner, parser, emitter, constructor, representer, and resolver modules) with an optional Cython extension (lib/_yaml/_yaml.pyx) that binds to the C libyaml library for the CSafeLoader/CDumper fast path. Packaging uses a custom PEP 517 build backend (packaging/) driven by setup.py and pyproject.toml, which probes for a system libyaml install and conditionally builds the Cython extension; when libyaml isn’t available, PyYAML falls back transparently to the pure-Python implementation.

Code Quality The tests/ directory includes both a modern pytest-based suite (test_dump_load.py, test_merge.py) and an extensive legacy suite (tests/legacy_tests/) covering structure, constructors, representers, resolvers, error handling, and round-trip canonical-YAML fixtures — a strong signal of correctness coverage for a spec-implementing library, though the codebase predates modern Python type hints and does not use static typing throughout. Security-sensitive code paths are explicit: BaseConstructor.check_state_key() blacklists dunder/state keys during deserialization to reduce (but not eliminate) the risk of yaml.load() on untrusted input, and the CHANGES file documents a long history of CVE-driven hardening (safe-by-default behavior was added specifically in response to arbitrary-code-execution reports).

API Design The public API is deliberately minimal and mirrors Python’s own pickle/json module conventions (load/dump, safe_load/safe_dump), which makes onboarding nearly instant for any Python developer. The main ergonomic sharp edge — needing to pick a Loader class and understanding the safe-vs-unsafe distinction — is well documented in the README and is the single most important thing new users must learn; beyond that, extension points (registering custom constructors/representers for new tags) are straightforward subclassing patterns.

Used by 90 apps in this directory

TypeScript
53%
Apache 2.0

Flowsint

Automation · Developer Tools

9,911

A privacy-first, graph-based OSINT investigation platform with 30+ automated enrichers for mapping relationships between domains, IPs, people, and organizations.

View details
85
Repo Health
71
Technical
67
Dependency
Built with
TypeScript 53%
Python 45%
Updated 1 weeks ago
TypeScript
91%
Other

GitNexus

AI Code Assistants · Developer Tools · Mcp

48,014

Index any codebase into an interactive knowledge graph and give your AI agents deep architectural context via MCP — with zero servers required.

View details
88
Repo Health
86
Technical
70
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
Python
71%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

30,269

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
90
Repo Health
91
Technical
64
Dependency
Built with
Python 71%
TypeScript 18%
Updated 2 weeks ago
Python
82%
Apache 2.0

headroom

AI Development · Developer Tools

77,676

Compress everything your AI agent reads — tool outputs, logs, RAG chunks, and files — before it reaches the LLM, achieving 60–95% fewer tokens with the same answers.

View details
85
Repo Health
86
Technical
69
Dependency
Built with
Python 82%
Rust 12%
Updated 6 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
74
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 6 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
74
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 6 days ago
HTML
45%
LGPL-2.1

Horilla

ERP · Human Resources

1,470

Open-source HRMS covering recruitment, attendance, payroll, and biometrics in one self-hosted Django application.

View details
91
Repo Health
60
Technical
64
Dependency
Built with
HTML 45%
Python 41%
JavaScript 11%
Updated 1 weeks ago
Python
100%
MIT

hyperresearch

AI Agents · Developer Tools · Knowledge Management

3,940

A tier-adaptive 16-step deep research pipeline for Claude Code that produces adversarially-audited reports with full source provenance, backed by a persistent, searchable vault.

View details
81
Repo Health
85
Technical
73
Dependency
Built with
Python 100%
Updated 2 weeks ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,433

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
88
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers