--- id: python-datauri version: "3.0.2" license: Unlicense license_treatment: permissive maintenance: dormant --- # python-datauri — A li'l class for data URI manipulation in Python License: permissive · Maintenance: dormant · Downloads: 328.1K/mo ## What it is and what it does python-datauri is a lightweight class for parsing and creating data URIs—the inline data scheme used to embed files, images, and text directly in URLs. It handles the common case of extracting or encoding a mimetype, charset, and base64 flag, then provides access to the decoded payload as bytes or text. The package is intentionally minimal and does not attempt to validate all edge cases; it focuses on the practical subset most developers need. You use it to parse existing data URIs into their components (mimetype, charset, raw data) or to construct new ones from strings or files. It integrates with Pydantic for type validation in data models. The implementation depends only on cached-property and typing_extensions, making it a low-friction addition to any project that needs to work with embedded data URIs. Use it for: - Extract image data from a data URI embedded in HTML or JSON to save to disk or process - Encode a file as a data URI for embedding in web pages or API responses - Parse and validate data URIs in Pydantic models for REST APIs that accept inline uploads - Convert between string and binary representations of embedded data without external libraries - Build data URIs programmatically for testing or generating HTML with inline assets ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses and creates data URIs, extracting or encoding mimetype, charset, and base64 flags with minimal validation. Yes, if you work with data URIs regularly. The package is stable, permissively licensed, has no security vulnerabilities, and requires minimal dependencies. Dormant maintenance is not a concern for a focused utility that does one thing well. Install it when you need to parse or create data URIs; skip it if you only handle them occasionally or can use simpler string manipulation. ## Install pip install python-datauri uv add python-datauri poetry add python-datauri ## Installing python-datauri Before you install: Low friction: pure Python wheel with only two lightweight runtime dependencies (cached-property and typing_extensions). Dormant maintenance since 588 days ago, though the repository remains active with a recent commit on 2025-01-03. License in practice: Released under the Unlicense, a permissive public-domain equivalent that places no restrictions on use, modification, or distribution. Quickstart: from datauri import DataURI # Parse a data URI uri = DataURI('data:text/plain;charset=utf-8;base64,VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu') print(uri.mimetype) # 'text/plain' print(uri.data) # b'The quick brown fox jumped over the lazy dog.' # Create from string made = DataURI.make('text/plain', charset='us-ascii', base64=True, data='This is a message.') print(str(made)) # 'data:text/plain;charset=us-ascii;base64,...' Verify before relying: - Whether the package handles all valid data URIs or only the subset described as 'most useful' - Performance characteristics with large embedded data or many URI operations - Whether Pydantic integration requires additional setup beyond the example shown ## Package facts - License: Unlicense (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 328.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags data uri parsing, data uri encoding, base64 data uri, mimetype extraction, inline data uri, data url handling, uri serialization, data-uri, base64-encoding, web-utilities [View on SkillFed](https://skillfed.io/packages/python-datauri) · [View on PyPI](https://pypi.org/project/python-datauri/)