Why it matters

Prompt sanitization shapes safety. Understanding shapes design.

Advertisement

The architecture

Trim + normalize.

Escape delimiters + control chars.

Length limits.

Optional PII / injection detection.

Prompt sanitization stackNormalizeunicode + whitespaceEscapedelimiters + controlLength + safetycap + detectEscape XML tags + delimiters used by system prompt; unicode normalize
Prompt sanitization.
Advertisement

How it works end to end

Unicode normalization (NFKC).

Escape system delimiters.

Length caps.

Injection detection layer.