parse
parse() is the opposite of format()
What it is and what it does
Parse is a string-parsing library that inverts Python's format() function: instead of inserting values into a template, it extracts values from a formatted string using the same template syntax. You define a pattern with placeholders like `{}` or named fields like `{name}`, and parse() returns the matched values as a Result object with both positional and named access.
The library supports format specifications for type conversion (integers, floats, dates, hex, binary, and regex character classes), alignment and width handling, and both case-sensitive and case-insensitive matching. It has no external dependencies and is lightweight enough for embedded use in data extraction pipelines, log parsing, or configuration file parsing.
Use it for:
- Extract fields from log lines or structured text output without regex
- Parse configuration files or reports with consistent formatting
- Convert formatted strings back to typed Python objects (dates, numbers, etc.)
- Build data extraction pipelines where format patterns are more readable than regex
- Match and capture groups from text using Python's familiar format syntax
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parse strings using format-string-like patterns to extract structured data, reversing the operation of Python's format() function.
Yes. Parse is lightweight, dependency-free, actively maintained, MIT-licensed, and solves a real problem—extracting data from formatted strings is more readable with parse() than with regex for many common cases. No known vulnerabilities. Install it if you need to reverse format() operations or prefer format-string patterns over regex for text extraction.
Install
parse on PyPI
pip
pip install parseuv
uv add parsepoetry
poetry add parseInstalling parse
Before you install
Installs cleanly with no runtime dependencies and maintains active status with recent releases.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
from parse import parse, compile
# Simple extraction
result = parse("It's {}, I love it!", "It's spam, I love it!")
print(result[0]) # 'spam'
# Typed extraction
result = parse('Age: {:d}', 'Age: 42')
print(result[0]) # 42
# Compiled pattern for reuse
p = compile("The {} who {}")
result = p.parse("The knights who say Ni!")
print(result.fixed) # ('knights', 'say')
Verify before relying
- Whether the package supports Python 2 despite the wheel name suggesting it (parse-1.22.1-py2.py3-none-any.whl vs requires_python unspecified)
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 80 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 18,038,649/month — #1,088 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: parse-1.22.1-py2.py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
dateformatParses strings into datetime objects and…
permissive · top 15,000 on PyPI
FixedWidthConverts between Python dictionaries and…
permissive · top 5,000 on PyPI
iso8601Parses ISO 8601 date strings (e.g.…
permissive · top 5,000 on PyPI
isodurationParses and manipulates ISO 8601 duration…
permissive · top 1,000 on PyPI
aniso8601Parses ISO 8601 date, time, datetime, duration,…
permissive · top 5,000 on PyPI
ctparseParses natural language time expressions (like…
permissive · top 15,000 on PyPI
isodateParses and formats ISO 8601 date, time,…
permissive · top 1,000 on PyPI
metomi-isodatetimeParses and manipulates ISO 8601 date-time…
copyleft · top 15,000 on PyPI
datefinderDatefinder extracts date and time expressions…
permissive · top 5,000 on PyPI
price-parserExtracts price amounts and currency symbols…
permissive · top 5,000 on PyPI