skillfed

parse

parse() is the opposite of format()

parse v1.22.1 18.0M downloads/30d#1,088 on PyPI1,790
Permissive license MIT Active released

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 parse

uv

uv add parse

poetry

poetry add parse

Installing 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

Environment :: Web EnvironmentIntended Audience :: DevelopersProgramming Language :: Python :: 3Topic :: Software Development :: Code GeneratorsTopic :: Software Development :: Libraries :: Python Modules

Tags

string parsing with format patternsextract data from formatted stringsformat string reversepattern matching text extractionparse structured text dataformat() oppositestring template matching
string-parsingdata-extractiontext-processing

More Python Modules packages