{
 "kind": "tool",
 "slug": "pyyaml",
 "path": "tools/pyyaml/",
 "name": "PyYAML",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Utilities",
   "tools/utilities/"
  ]
 ],
 "lead": "Read and write settings files in Python.",
 "chips": [
  {
   "label": "Utilities",
   "path": "tools/utilities/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install pyyaml"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/yaml/pyyaml"
  },
  {
   "label": "Website",
   "href": "https://pyyaml.org/"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software",
   "note": "MIT allows use in paid and closed-source products.",
   "src": "https://github.com/yaml/pyyaml/blob/main/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 20, 2026",
   "note": "Latest GitHub release Nov 20, 2026. ",
   "src": "https://github.com/yaml/pyyaml"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "371 projects",
   "status": "info",
   "sub": "#3 of 408 in its category",
   "note": "Dependency in 371 public GitHub projects set up for AI coding agents that we scanned (5.9%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What PyYAML does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Read your app's settings file",
       "text": "Shop name, languages and limits live in one readable file; your app loads them at start instead of hard-coding them.",
       "idea": false
      },
      {
       "title": "Save data as a readable file",
       "text": "Your app writes its settings or an export so a person can open and edit it in any text editor.",
       "idea": false
      },
      {
       "title": "Open files people upload",
       "text": "Users upload a settings or data file; your app reads only plain data from it and never runs code hidden inside.",
       "idea": false
      },
      {
       "title": "Read multi-part deployment files",
       "text": "One file holds several blocks split by --- lines, as server setup files often do; your script reads each block in turn.",
       "idea": false
      },
      {
       "title": "Edit blog post headers",
       "text": "Markdown posts start with a short settings block (title, date, draft); a script flips draft to false before publishing.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "PyYAML popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "76",
       "of": "/ 100",
       "l": "Gid Score, #180 overall"
      },
      {
       "n": "322M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "2,985",
       "l": "GitHub stars"
      },
      {
       "n": "371",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How PyYAML is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "216 projects, 6.6%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "159 projects, 5.2%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "139 projects, 5.7%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "43 projects, 12.9%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "30 projects, 6.3%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "22 projects, 4.7%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "17 projects, 6.1%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "17 projects, 5.0%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 49.3% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 44.7% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 41.2% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 39.1% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 36.1% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 34.8% of its projects",
       "v": "NumPy",
       "path": "tools/numpy/"
      },
      {
       "l": "In 33.2% of its projects",
       "v": "Rich",
       "path": "tools/rich/"
      },
      {
       "l": "In 25.6% of its projects",
       "v": "pandas",
       "path": "tools/pandas/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "PyYAML in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "A C parser and emitter, one argument away",
       "v": "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\"."
      },
      {
       "l": "Three install-time choices for the C bindings",
       "v": "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."
      },
      {
       "l": "Both backends tested, local LibYAML build pinned",
       "v": "<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."
      },
      {
       "l": "PyYAML releases listed from 3.01 (2006-05-07)",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The fast path is opt-in twice",
       "v": "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."
      },
      {
       "l": "Free-threading support is experimental",
       "v": "Release 6.0.3 adds support for Python 3.14. Its free-threading support is marked experimental."
      },
      {
       "l": "Website and README list different chat channels",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "C loader and dumper, and loading untrusted input"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Python",
       "code": ">>> yaml.load(stream, Loader=yaml.CLoader)\n>>> yaml.dump(data, Dumper=yaml.CDumper)\n>>> yaml.safe_load(stream)"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about PyYAML",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "pydantic: Data validation",
        "python-dotenv: .env file loading",
        "requests: HTTP client",
        "numpy: Numeric arrays",
        "uvicorn: ASGI server",
        "fastapi: Web API framework"
       ]
      },
      {
       "title": "More in Utilities",
       "path": "tools/utilities/",
       "items": [
        {
         "text": "clsx",
         "path": "tools/clsx/"
        },
        {
         "text": "date-fns",
         "path": "tools/date-fns/"
        },
        {
         "text": "uuid",
         "path": "tools/uuid/"
        },
        {
         "text": "yaml",
         "path": "tools/yaml/"
        },
        {
         "text": "js-yaml",
         "path": "tools/js-yaml/"
        },
        {
         "text": "glob",
         "path": "tools/glob/"
        },
        {
         "text": "Lodash",
         "path": "tools/lodash/"
        },
        {
         "text": "tqdm",
         "path": "tools/tqdm/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "PyYAML",
       "me": true,
       "facts": [
        "MIT",
        "Gid 76",
        "322M/wk"
       ]
      },
      {
       "name": "ruamel.yaml",
       "why": "Pick ruamel.yaml when you edit files people maintain by hand; it keeps comments, key order and formatting on a round trip.",
       "path": "tools/ruamel-yaml/",
       "facts": []
      },
      {
       "name": "js-yaml",
       "why": "Pick js-yaml when the code that reads the file is JavaScript or Node.js rather than Python.",
       "path": "tools/js-yaml/",
       "facts": []
      },
      {
       "name": "yaml",
       "why": "Pick the yaml package for JavaScript when you need full spec compliance and to keep comments in JavaScript code.",
       "path": "tools/yaml/",
       "facts": []
      }
     ],
     "more": "Compare PyYAML with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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)."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install PyYAML into your project's Python environment. Note: the package is named PyYAML, but you import yaml.",
       "code": "pip install pyyaml\n",
       "src": "https://pyyaml.org/wiki/PyYAMLDocumentation"
      },
      {
       "text": "Read files you did not write yourself with safe_load, never plain load.",
       "code": "yaml.safe_load(stream)\n",
       "src": "https://github.com/yaml/pyyaml/blob/main/README.md"
      },
      {
       "text": "Write data back with safe_dump; pass sort_keys=False to keep your key order.",
       "code": null,
       "src": "https://pyyaml.org/wiki/PyYAMLDocumentation"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## PyYAML\n- For any YAML stream you don't trust, use `yaml.safe_load(stream)`, as the README instructs.\n- Only pass `Loader=yaml.CLoader` / `Dumper=yaml.CDumper` when the LibYAML bindings are installed.\n- To control the C build from source, use `python setup.py --with-libyaml install` (force) or `python setup.py --without-libyaml install` (skip).\n- When changing PyYAML itself, run `make test` to cover both backends. Use `make test-python` or `make test-libyaml` for one mode.\n- To test against a specific interpreter, set it explicitly, e.g. `make test PYTHON-VERSION=3.13.5`.\n- Treat free-threading support on Python 3.14 as experimental (added in 6.0.3).\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "yaml.load(text)",
       "fix": "yaml.safe_load(text)",
       "why": "Since 6.0 load() without Loader= raises TypeError (our run), and load with the full loader is unsafe for untrusted input."
      },
      {
       "dont": "country: NO / debug: off / version: 1.10 left unquoted",
       "fix": "country: 'NO' / version: '1.10' in the file, or set the values as strings before safe_dump",
       "why": "Our run read NO and off as False and 1.10 as the number 1.1."
      },
      {
       "dont": "yaml.safe_dump(data) and expecting the original key order and non-English text as written",
       "fix": "yaml.safe_dump(data, sort_keys=False, allow_unicode=True)",
       "why": "In our run the defaults sorted keys alphabetically and wrote Cyrillic text as \\u escape codes."
      },
      {
       "dont": "Load, change and save a hand-edited config with PyYAML",
       "fix": "Use ruamel.yaml for round trips where comments must survive",
       "why": "In our run the comment lines of config.yaml were gone after safe_dump."
      },
      {
       "dont": "pip install yaml",
       "fix": "pip install pyyaml (then import yaml)",
       "why": "The package on PyPI is PyYAML; the import name is yaml."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Can I use it in a paid, closed-source app?",
       "a": "Yes. It is MIT-licensed; keep the copyright and license notice with its files.",
       "evidence": {
        "url": "https://github.com/yaml/pyyaml/blob/main/LICENSE",
        "quote": "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."
       }
      },
      {
       "q": "Why does yaml.load(text) fail with \"missing 1 required positional argument: 'Loader'\"?",
       "a": "Since version 6.0 load needs a Loader. Use yaml.safe_load(text) instead (our run showed this TypeError).",
       "evidence": {
        "url": "https://github.com/yaml/pyyaml/blob/main/CHANGES",
        "quote": "always require `Loader` arg to `yaml.load()`"
       }
      },
      {
       "q": "Is FullLoader or full_load safe for untrusted files?",
       "a": "The project's own page says to avoid it for untrusted data; use safe_load.",
       "evidence": {
        "url": "https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation",
        "quote": "WARNING : As of pyyaml-5.3.1 there are still trivial exploits. Do not use this on untrusted data for now."
       }
      },
      {
       "q": "Why did my value \"NO\" become False?",
       "a": "PyYAML reads on, off, yes, no and similar words as true or false. Put such values in quotes in the file.",
       "evidence": {
        "url": "https://pyyaml.org/wiki/PyYAMLDocumentation",
        "quote": "'bool' : [ True , False , True , False ]}"
       }
      },
      {
       "q": "Is there a faster mode?",
       "a": "Yes. When the LibYAML C parser is present, CLoader and CDumper are much faster; the PyPI wheels in our run had it built in.",
       "evidence": {
        "url": "https://pyyaml.org/wiki/PyYAMLDocumentation",
        "quote": "If you want to use LibYAML bindings, which are much faster than the pure Python version, you need to download and install LibYAML ."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi pyyaml"
  ],
  [
   "Category",
   "Utilities"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "6.0.3, September 25, 2025"
  ],
  [
   "On GitHub since",
   "November 2011"
  ],
  [
   "Gid Score",
   "75.9"
  ],
  [
   "Rank in category",
   "#3 of 408"
  ],
  [
   "GitHub",
   "yaml/pyyaml"
  ],
  [
   "Last change",
   "Nov 20, 2026"
  ]
 ],
 "good": [
  "Plain yaml.load can run code hidden in a file. Use safe_load for anything from users, uploads or the internet.",
  "It follows an older version of the format, so on, off, yes, no and similar words turn into true or false.",
  "safe_load reads only the first part of a file split by --- lines. Use safe_load_all to get every part."
 ],
 "checked_line": "Read by AgentGid from 8 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/yaml.png"
}