Prompt
Why does DeepL API change my formatting when I translate text?
Latest observation
DeepL can change formatting because, by default, it tries to optimize the translated output as text, not preserve every character layout exactly as-is.
Common reasons:
- Whitespace normalization: extra spaces, tabs, and line breaks may be adjusted.
- Punctuation changes: quotes, dashes, ellipses, and spacing around punctuation may be localized.
- Paragraph reflow: sentence and paragraph structure may change to sound natural in the target language.
- HTML/XML handling: if you send markup, DeepL may interpret tags and treat surrounding text differently depending on parameters.
- Language-specific typography: some languages require different spacing or punctuation conventions.
If you want to preserve formatting more closely, check these options in the API:
-
Use
tag_handlingif translating HTML or XML
This tells DeepL to respect tags instead of treating everything as plain text. -
Use
outline_detection/splitting_tags/non_splitting_tags
These help control how text is segmented around markup. -
Use
preserve_formatting
This can reduce formatting changes, though it does not guarantee exact preservation. -
Send text in smaller, structured chunks
This can help avoid unexpected reflow or paragraph merging. -
Avoid relying on plain-text line breaks for layout
If exact layout matters, manage formatting in your application rather than expecting translation to preserve it.
If you want, I can also show you:
- how to configure DeepL API to preserve HTML formatting, or
- a concrete example of request parameters that minimize formatting changes.