PyYAML

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

Library
PyPI
v6.0.3
2,938stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
57/100Fair
Development Activity28
Maintenance24
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality78
Innovation68
Learning Curve85

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 58 apps in this directory

Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
49%
Other

Airbyte

Developer Tools · Data Engineering

21,916

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python49%
Kotlin42%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
Python
54%
Other

authentik

Authentication · Security

24,980

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Python54%
TypeScript33%
Updated today
Python
62%
MIT

AutoGen

AI Development · Automation

60,518

Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.

View details
57
Repo Health
78
Technical
75
Dependency
Built with
Python62%
C#25%
TypeScript12%
Updated 4 months ago
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today

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

Search