skillfed

commented-configparser

A custom ConfigParser class that preserves comments and most formatting when writing loaded config out.

commented-configparser v3.0.0 501.4K downloads/30d#6,315 on PyPI10
Permissive license MIT AGING released

What it is and what it does

commented-configparser is a drop-in replacement for Python's standard library ConfigParser that preserves comments and most formatting when you read and write configuration files. When you load an INI file, modify it, and save it back, your original comments stay in place—a feature the standard library discards. The package normalizes spacing around assignment operators and does not preserve indentation outside of multi-line values, but it retains both hash and semicolon comments, blank lines between sections, and trailing comments.

You use it exactly like the standard ConfigParser: instantiate it, call read() to load a file, modify the configuration as needed, and call write() to save it back. It has no external dependencies and runs on Python 3.9 and later, making it a lightweight addition to projects that need to edit configuration files while respecting user comments.

Use it for:

  • Edit application config files programmatically while preserving user comments and structure.
  • Build configuration management tools that round-trip INI files without losing documentation.
  • Maintain configuration templates where comments explain each setting to end users.
  • Update config values in scripts while keeping inline and section-level comments intact.
  • Generate or modify INI files from code and have them remain human-readable and annotated.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Extends Python's standard ConfigParser to preserve comments and formatting when reading and writing INI-style configuration files.

Yes, if you need to programmatically edit INI configuration files while preserving comments. The package is lightweight, has no dependencies, and solves a real gap in the standard library. Maintenance is aging but the repository is not abandoned; consider it stable for its narrow use case. No known security issues.

Install

commented-configparser on PyPI

pip

pip install commented-configparser

uv

uv add commented-configparser

poetry

poetry add commented-configparser

Installing commented-configparser

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 418 days ago, though the repository remains active and the package supports current Python versions (3.9+).

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

from commentedconfigparser import CommentedConfigParser

config = CommentedConfigParser()
config.read("myconfig.ini")
# modify config as needed
with open("myconfig.ini", "w") as f:
    config.write(f)

Requires Python 3.9 or later.

Verify before relying

  • Whether indentation outside multi-line values is truly lost or recoverable in edge cases.
  • Performance characteristics when handling very large configuration files.
  • Compatibility with ConfigParser subclasses or custom interpolation schemes.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 418 days since the last release
Last repo commit
First released
Downloads 501,381/month — #6,315 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: commented_configparser-3.0.0-py3-none-any.whl

Programming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPython

Tags

configparser preserve commentsini file comment preservationconfig file formatting retentioncommented config parserini parser with commentsconfiguration file editormaintain config comments
config-managementini-files

More Utilities packages