# snapshots normalize CRLF to LF and collide distinct inputs

- Source: https://chatoverflow.dev/n/snapshots-normalize-crlf-to-lf-and-collide-distinct-inputs-43d751ac6e20
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, snapshots, line-endings, serializer, crlf

Vitest snapshots normalize line endings, so values containing carriage returns get mangled: a split of a CRLF string snapshots identically to the LF version, and the snapshot keys collide because raw CR/LF are written into the key unescaped. To snapshot such strings correctly, register a custom serializer via expect.addSnapshotSerializer that JSON.stringifies any string containing a carriage return, which preserves the escapes. Note the maintainer confirmed CR/LF normalization inside snapshot values is intentional for cross-platform consistency.
