rfc 5322 · unfold · refold · live

Format email headers + DKIM

Unfolds continuation lines, normalises whitespace, then refolds long DKIM and Received values at semicolons for readable inspection. Runs locally.

Email Headers Formatter
Input
368 B
10 lines
Output
387 B
13 lines
Status
ready
live
Ratio
1.05×
out/in
input · email headers
output · folded headers
From: alice@example.com
To: bob@example.com
DKIM-Signature: v=1; 
  a=rsa-sha256; 
  c=relaxed/relaxed; 
  d=example.com; 
  s=selector1; 
  h=From:To:Subject:Date:Message-ID; 
  bh=abc123; 
  b=def456==
Received: from mail.example.com (mail.example.com [192.0.2.1]) by mx.recipient.com with ESMTPS id ABC123 for <bob@example.com>; 
  Mon, 20 May 2026 09:15:00 +0000
Subject: Hello world
Quick Start

How email header folding works

RFC 5322 lets a header value wrap over multiple lines if continuation lines start with whitespace (LWSP). This tool unfolds first, then refolds at logical boundaries.

  1. 01

    Paste raw headers

    The block before the first blank line in a .eml file, or the headers section of a bounce report.

    Parsing runs through Prettier’s standalone bundle (or the language-specific equivalent) loaded lazily — no parser ships until the tool is opened.

    emailPrettierASTstandalonelazy
    input · sourceraw · AST
    From: a@b
    DKIM-Sig: v=1;
    loaded · parsedAST · ready
  2. 02

    Unfold continuations

    Lines starting with space or tab attach to the previous header's value.

    Indent width, tab style, and print-width re-format through a memoised pass — switching 2 → 4 spaces never re-parses, only re-prints.

    unfoldindentprint-widthmemoisedlive
    join · optionslwsp · live
     cont → joined
    options applied · livelive
  3. 03

    Refold at ; boundaries

    Values longer than 78 chars wrap at semicolons — natural for DKIM, Received, and SPF.

    The formatter is deterministic and idempotent: running it twice produces byte-identical output, which keeps diffs and git noise to a minimum.

    refoldidempotentdeterministicdiff-cleanstable
    wrap · formatted>78 · ready
    DKIM-Sig: v=1;
      d=ex.com;
    formatted · liveidempotent
  4. 04

    Copy or save

    Use the readable form for an audit, then re-encode with the original folding for actual sending.

    Download writes a Blob with the language-appropriate extension; copy uses navigator.clipboard.writeText so the output preserves all whitespace exactly.

    exportclipboardbloblanguage MIMEclient-side
    ok · copiedready · done
    ✓ Copied
    shipped · ready to shipsuccess
Pro tips

Formatting tips that keep diffs sane

Pick one config and pin it

Inconsistent formatting causes diff churn. Commit .prettierrc / .editorconfig and enforce in CI.

Format on save

Editor integration is faster feedback than a pre-commit hook. Use both for belt-and-braces.

Idempotency matters

Running the formatter twice should produce identical output. Test this on a representative file.

Match the language community

Default to community conventions: 2 spaces for JS/CSS, 4 for Python, tabs for Go. Fights over indent are a productivity tax.

Print-width drives wrapping

80, 100, and 120 are the common targets. Wider lines parse fast but review slower side-by-side.

Don&rsquo;t mix formatters and linters

Prettier handles whitespace; ESLint handles correctness. Disable overlapping rules to avoid fight-club configs.

Use Cases

When to format headers

DKIM debugging, deliverability audits, forensics.

DKIM debugging

Read selector, domain, and signed-header list at a glance. Idempotent: running the formatter twice produces byte-identical output, which is the foundation of a clean CI gate. Pair with a pre-commit hook so PRs arrive already formatted, focusing review on logic.

idempotent

SPF / DMARC

Inspect Authentication-Results without horizontal scroll. Pairs with EditorConfig + .prettierrc for end-to-end consistency. Whitespace-only changes vanish so reviewers see real diffs, and git blame stays honest about who wrote what.

CI-ready

Phishing review

Examine Received chains to trace an email's actual path. Output respects your indent width, tab style, and print-width — settings carry over for repeat runs. Switching 2-space to 4-space costs nothing in CPU but standardises an entire codebase.

diff-clean

Bounce parsing

Make NDR headers legible for support tickets. Format-on-save is the fastest feedback loop; CI is the safety net. Together they make inconsistent indentation a thing of the past and free up review cycles for genuine concerns.

PR-friendly

Mail gateway tuning

Compare headers before and after a relay rewrites them. Whitespace-only changes don't trigger downstream content-hash invalidations, so CDN cache keys and CI cache layers stay warm. Real changes get all the rebuild budget.

review-ready

Compliance

Capture headers as evidence in a readable form. Pairs with linters (ESLint, Stylelint, pylint) that catch what formatting alone can't — bugs, unused imports, dead code. Each tool stays in its lane, and the codebase stays clean.

deterministic
FAQ

Frequently asked questions

No. Refolding changes whitespace, which would break the canonicalized signature — use it for inspection only.
Encoded-word headers (=?utf-8?B?...?=) are left as-is; the tool doesn't decode them.
RFC 5322 recommends lines stay under 78 chars; values longer than that fold at ; boundaries here.
No — order is preserved. Re-ordering would break some authentication results.
No — formatting runs locally in your browser tab.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!