#ini-parser #config-parser #round-trip #ini-config #preserve #ini

ini-preserve

Format-preserving INI parser — read, modify and write back INI files without losing comments, ordering or formatting

3 releases

0.1.2 Jul 24, 2026
0.1.1 Mar 31, 2026
0.1.0 Mar 31, 2026

#1802 in Configuration

Download history 9/week @ 2026-04-15 5/week @ 2026-04-22 58/week @ 2026-04-29 3/week @ 2026-05-06 31/week @ 2026-05-27 11/week @ 2026-06-10 22/week @ 2026-06-17 29/week @ 2026-06-24 82/week @ 2026-07-01 33/week @ 2026-07-08 14/week @ 2026-07-15 23/week @ 2026-07-22 174/week @ 2026-07-29

273 downloads per month
Used in pinready

MIT license

24KB
474 lines

ini-preserve

Crates.io Documentation License: MIT Discord

Format-preserving INI parser for Rust.

Read, modify and write back INI files without losing comments, ordering or formatting.

Unlike most INI parsers that discard comments and reorder sections when writing, ini-preserve keeps the original file structure intact. Only the values you explicitly change are modified. Everything else (comments, blank lines, key order, spacing around =) is preserved.

Community & support

Questions, bug reports, beta testing, or just want to chat? Join the Discord:

Discord

Features

  • Round-trip safe — parse and write back produces identical output
  • Comments preserved; and # comment lines are kept as-is
  • Ordering preserved — sections and keys stay in their original order
  • Spacing preservedKey=Value, Key = Value, Key =Value all keep their style
  • Semicolons in valuesKey = foo;bar works correctly (; is not treated as inline comment)
  • Atomic writessave() writes to a temp file then renames
  • No dependencies — pure Rust, no external crates
  • Simple APIload(), get(), set(), save()

Usage

use ini_preserve::Ini;

// Load an existing INI file
let mut ini = Ini::load("config.ini").unwrap();

// Read values
if let Some(value) = ini.get("Player", "Width") {
    println!("Width = {}", value);
}

// Modify values (only changed lines are rewritten)
ini.set("Player", "Width", "3840");
ini.set("Player", "Height", "2160");

// Save back — comments and formatting preserved
ini.save("config.ini").unwrap();

Why?

Many applications (like VPinballX) generate INI files with extensive comments documenting every setting and its default value. Using a standard INI parser to modify one value destroys all those comments. ini-preserve solves this by treating the file as a sequence of lines and only modifying the specific lines that need to change.

License

MIT

No runtime deps