skillfed

python-datauri

A li'l class for data URI manipulation in Python

python-datauri v3.0.2 328.1K downloads/30d#7,559 on PyPI58
Permissive license Unlicense DORMANT released

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 on this page — 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

python-datauri on PyPI

pip

pip install python-datauri

uv

uv add python-datauri

poetry

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 not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — cached-property, typing_extensions
Maintenance dormant — 588 days since the last release
Last repo commit
First released
Downloads 328,132/month — #7,559 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_datauri-3.0.2-py2.py3-none-any.whl

Development Status :: 4 - BetaLicense :: OSI Approved :: The Unlicense (Unlicense)Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

data uri parsingdata uri encodingbase64 data urimimetype extractioninline data uridata url handlinguri serialization
data-uribase64-encodingweb-utilities

More Internet packages