exform

Reshape text by example — give a couple of before → after examples, and exform infers the transform and applies it to every line.
deterministic
offline
no LLM · no API key
zero deps

1 · Examples (before → after)

2 · Your data (one item per line)

3 · Output


    

Inferred program (--explain)

Booting Python (Pyodide)… first load is a few seconds.

Prefer the terminal?

pipx install exform        # or: uvx exform / pip install exform

echo "1234567890" | exform -e "5551234567 => (555) 123-4567"
(123) 456-7890

Common tasks exform solves

Every recipe below is the real tool output. You give a couple of before → after examples; exform figures out the rule and applies it to every line — no regex, no LLM, no API key.

Swap “Last, First” into “First Last” in a text file

$ cat names.txt | exform -e 'Doe, John => John Doe' -e 'Smith, Jane => Jane Smith'
Doe, John
Smith, Jane
Turing, Alan
John Doe
Jane Smith
Alan Turing

Two examples are enough — the third line was never shown to exform.

Reorder date columns (ISO → DD/MM/YYYY)

$ cat dates.txt | exform -e '2000-01-15 => 15/01/2000' -e '2024-07-04 => 04/07/2024'
2000-01-15
2024-07-04
1999-12-31
15/01/2000
04/07/2024
31/12/1999

Extract the domain from a list of email addresses

$ cat emails.txt | exform -e 'ada@math.org => math.org' -e 'grace@navy.mil => navy.mil'
ada@math.org
grace@navy.mil
math.org
navy.mil

Zero-pad numbers to a fixed width

$ cat ids.txt | exform -e '5 => 00005' -e '42 => 00042'
5
42
1234
00005
00042
01234

Format raw digits into a phone number

$ cat phones.txt | exform -e '1234567890 => (123) 456-7890' -e '5559876543 => (555) 987-6543'
1234567890
5559876543
(123) 456-7890
(555) 987-6543

Reshape one field inside JSONL — “jq by example”

$ cat users.jsonl | exform --json-field user.name -e 'Doe, John => John Doe' -e 'Lovelace, Ada => Ada Lovelace'
{"user": {"name": "Doe, John"}, "age": 41}
{"user": {"name": "Lovelace, Ada"}, "age": 36}
{"user": {"name": "John Doe"}, "age": 41}
{"user": {"name": "Ada Lovelace"}, "age": 36}

Only the targeted field changes; every other key, nesting and type is preserved.

Turn a transform into a portable awk one-liner

$ exform -e 'John,Doe,NYC => Doe John' -e 'Ada,Lovelace,London => Lovelace Ada' --emit awk
awk -F, '{ print $2 " " $1 }'

exform infers the rule, then hands you awk you can paste anywhere — and it refuses to print an awk program that disagrees with your examples.

Install: pipx install exform · uvx exform · pip install exform — or grab the zero-dependency exform.pyz. Full cookbook in the README.