Hi OpenAI team and community,
I ran into an issue with GPT‑4.1‑mini when using structured JSON outputs.
Whenever the model generated curly quotes (“ ”
), plus signs (+
), or dashes (–
), the JSON output contained escaped Unicode or hex codes such as:
Select \x002B New\x0022 in the Command Bar to open the FB \x002D Account using Google.
Instead of:
Select "+ New" in the Command Bar to open the FB - Account using Google.
Regex Solution That Works
Before passing the model input, I normalize the text by replacing curly quotes and dashes with ASCII equivalents:
import re
# Replace curly quotes with straight quotes
text = re.sub(r'[“”]', '"', text)
# Replace en-dash/em-dash with hyphen
text = re.sub(r'[–—]', '-', text)
Result:
Select "+ New" in the Command Bar. This action will open the FB - Account using Google
Has anyone else run into this? Any official recommendation to prevent the escaping at the model output level?