requirements.txt ↔ pyproject.toml Converter

Convert between Python requirements.txt and pyproject.toml dependency formats with real-time validation.

About This Tool

The requirements.txt to pyproject.toml Converter is a free, browser-based utility that transforms Python dependency declarations between the traditional requirements.txt format and the modern pyproject.toml format defined by PEP 621. Whether you are migrating a legacy project to the PEP 621 standard or extracting a flat dependency list from a pyproject.toml, this tool handles the conversion instantly.

Python's packaging ecosystem has evolved significantly. For years, requirements.txt was the de facto standard for pinning dependencies: one package per line with version specifiers like ==, >=, or ~=. With the introduction of PEP 518 and PEP 621, the Python community standardized on pyproject.toml as the single source of truth for project metadata, including dependencies. Tools like pip, poetry, hatch, flit, and pdm all support pyproject.toml natively.

The converter supports the full range of PEP 440 version specifiers (==, >=, <=, !=, ~=, >, <), extras such as requests[security], optional dependency groups (e.g., [project.optional-dependencies]), and PEP 508 environment markers like ; python_version >= "3.8". Comments in requirements.txt are preserved, and -r include directives are flagged so you can handle them manually.

All processing runs entirely in your browser using native JavaScript string parsing. No data is sent to any server -- there are no network requests, logging, or third-party services involved. This makes it safe to convert dependency files that may reference private package indexes or internal package names.

If you work with other configuration formats, check out the TOML to JSON Converter for general TOML manipulation, the JSON to YAML Converter for YAML workflows, or the JSON Formatter for validating JSON output.

How to Use

  1. Select the conversion direction using the toggle button: requirements.txt -> pyproject.toml or pyproject.toml -> requirements.txt.
  2. Paste your dependency content into the Input panel on the left. Alternatively, click Sample to load an example.
  3. The converted output appears instantly in the Output panel on the right as you type.
  4. Click Copy or press Ctrl+Shift+C to copy the output to your clipboard.
  5. Click Download to save the output as a file (pyproject.toml or requirements.txt).
  6. Use the Swap button to reverse the direction and move the current output into the input for round-trip conversion.
  7. Click Clear to reset both panels and start over.

Popular Conversion Examples

View all conversion examples →

FAQ

Is my data safe?

Yes. All conversion is performed entirely in your browser using native JavaScript string parsing. Your data never leaves your machine. There are no network requests, no logging, and no analytics on your input.

What version specifiers are supported?

The tool supports all PEP 440 version specifiers: == (exact), >= (minimum), <= (maximum), != (exclusion), ~= (compatible release), > (greater than), and < (less than). Compound specifiers like >=1.0,<2.0 are also supported.

Does it handle extras (optional dependencies)?

Yes. Extras like requests[security] or celery[redis,msgpack] are correctly parsed and preserved in both directions. When converting from pyproject.toml, [project.optional-dependencies] groups are converted to commented sections in requirements.txt.

What about environment markers?

PEP 508 environment markers such as ; python_version >= "3.8" or ; sys_platform != "win32" are fully supported in both directions. They are preserved exactly as specified.

Does it handle -r includes in requirements.txt?

The -r (include) and -- (option) directives cannot be directly represented in pyproject.toml. They are converted to comments noting that manual handling is needed.

What is pyproject.toml and why should I use it?

pyproject.toml is the standard configuration file for Python projects, defined by PEP 518 and PEP 621. It replaces setup.py, setup.cfg, and requirements.txt as the single source of truth for project metadata. Build tools like pip, poetry, hatch, flit, and pdm all support it natively.

What keyboard shortcuts are available?

Press Ctrl+Shift+C to copy the converted output to your clipboard.

Related Tools