How to prevent GPT from outputting responses in Markdown format?

Hello everyone,

I’m facing an issue with ChatGPT consistently delivering responses in Markdown, which is problematic for me because I use the generated text in a word processor for legal purposes.

I’ve tried several prompt engineering techniques, such as placing commands to remove Markdown at the beginning and end of the prompt, and using affirmative requests like “deliver the response in plain text with no formatting” or “give me the answer in pure text.” Unfortunately, none of these solutions have worked. GPT keeps generating responses in Markdown, and I’m left with the extra step of manually removing the formatting or asking ChatGPT again to clean the text from Markdown characters.

Does anyone have any advice or experience on how to permanently prevent ChatGPT from formatting outputs in Markdown? Any help would be appreciated, as this is adding unnecessary work to my process.

Thank you!

4 Likes

Hi @rodrigomartinsfaria :wave:

Welcome :people_hugging: to the community!

A kindly reminding; when you ask, if you show some sample outputs from ChatGPT, it can help community members to understand problem better and provide better solution.

BTW, you may try some following prompts. I hope, one of them can help you.

1- Specific Formats
Alternative format explicitly, such as “raw text” or even “JSON format”.

  • Example prompt:

Please deliver the response in plain text without any Markdown or formatting. Provide the output as raw text.

  • Alternative prompt:

Respond in JSON format with a key ‘response’ containing the pure text, no Markdown, no special characters.

2- Structured Delimiters
We can use delimiters like """ or --- and provide clear instructions for ChatGPT to only generate plain text within these delimiters.

  • Example prompt:

Please deliver the following response inside triple quotes (""") and ensure there is no Markdown formatting, no special characters, and no extra spaces. Deliver the response as plain text within the quotes.

"""
Deliver the response here in plain text without any formatting.
"""

3- Role based
We can make the GPT adopt a role that explicitly avoids formatting. This technique can help establish a consistent tone:

  • Example prompt:

You are a legal assistant writing formal documents. Ensure the response is in plain text without any Markdown or special formatting. Avoid bullet points, asterisks, or any symbols that indicate structured text.

4- CoT (Chain-of-thought) prompt
We can guide ChatGPT step-by-step through the task of stripping Markdown:

  • Example prompt:

First, generate the response with Markdown formatting. Then, in the next step, remove all Markdown characters and symbols. Deliver only the pure text with no formatting in the final output.

5- Clarify What Constitutes “Plain Text”
Sometimes, specifying what we mean by plain text in the context of our document needs helps.

  • Example prompt:

Provide the response as plain text, which means: no bold, no italics, no headers, no bullet points, no links, no code blocks. Just words, without any special characters.

5 Likes

All of your outputs from now on should be formatted in plaintext (without markdown formatting), and inside of a plaintext code block.

Example:
```plaintext
<your response>
```

Hi @rodrigomartinsfaria !

I found that it still refuses to listen to formatting instructions sometimes when I provide them in the chat, so for me adding these instructions under “Personalization” worked much better.

So if you go to ChatGPT Settings (in Desktop app, or website), and then Personalization → Customize ChatGPT → “How would you like ChatGPT to respond?”, you can then include an instruction similar to what @nicholishen wrote.

Bonus with this method is that it will always behave like this from now on, in newly initiated chats, so you don’t have to keep telling it to not output Markdown.

4 Likes

I add output to codebox at the end of these types of prompts.

I found that this prompt worked perfectly where I use it with the API and is truly great for its simplicity. Now I just need a single regex to remove the plaintext bracketing. Thanks! I was going nuts…

2 Likes

Thank you all for the answers, they all helped me a lot and gave me a lot of insights that will definitely solve my problem. :heart_eyes:

2 Likes

Use this:

System Instruction (Strict Markdown & Code Formatting Rules)

Markdown & Code Formatting Guidelines:

  • Always format code snippets with explicit language tags (elixir, yaml, json, markdown, etc.).
  • Never nest triple backticks (`````) inside another triple backtick block. Instead, use:
    • Four backticks (``````) for the outer block.
    • Tildes (~~~) as an alternative fencing style.
    • Custom delimiters (@@@@) if Markdown escaping is still necessary.
  • Escape Markdown inside Markdown:
    • If embedding a Markdown block within another, replace nested backticks with escaped versions (````).
    • Use raw HTML (<code>...</code>) when necessary to prevent unwanted formatting.
  • Inline Code Handling:
    • When an inline code snippet contains backticks, use double backticks ( example with backticks ``).
    • If the code starts or ends with a backtick, add a space inside the delimiter (e.g., example).
  • Handling Deep Nesting Cases:
    • If Markdown rendering still fails, use indentation-based code blocks (four-space indentation).
    • If Markdown breaks with multiple levels of nesting, manually verify before sending the response.
  • Prioritise Readability:
    • Always ensure code formatting is clean, structured, and does not introduce accidental Markdown parsing issues.
    • Test responses with complex nesting before finalising.

Special Cases & Additional Safeguards

If a Markdown response includes complex formatting (e.g., JSON inside Markdown inside an Elixir code block), ChatGPT will:

  1. Manually escape problem areas before sending.
  2. Provide alternative formatting recommendations if necessary (e.g., suggesting raw HTML encoding).
  3. Use warnings if a structure might break and offer a secondary formatted version.

— preformatted to copy paste:

- Always format code snippets with explicit language tags (elixir, yaml, json, markdown, etc.).
- Never nest triple backticks (```) inside another triple backtick block. 

Instead, use:

- Four backticks (````) for the outer block.
 - Tildes (~~~) as an alternative fencing style.
- Custom delimiters (@@@@) if Markdown escaping is still necessary.

Escape Markdown inside Markdown:

- If embedding a Markdown block within another, replace nested backticks with escaped versions (````).
- Use raw HTML (<code>...</code>) when necessary to prevent unwanted formatting.

Inline Code Handling:
- When an inline code snippet contains backticks, use double backticks ( `example with `backticks ``).
- If the code starts or ends with a backtick, add a space inside the delimiter (e.g., ` example `).

Handling Deep Nesting Cases:

- If Markdown rendering still fails, use indentation-based code blocks (four-space indentation).
- If Markdown breaks with multiple levels of nesting, manually verify before sending the response.

Prioritise Readability:

- Always ensure code formatting is clean, structured, and does not introduce accidental Markdown parsing issues.
- Test responses with complex nesting before finalizing.

@rodrigomartinsfaria

This worked perfectly for me by adding the following in the personalized GPT format settings:

“Deliver the response in plain text without any Markdown or formatting beside for code: no bold, no italic, no headings. Provide the output as raw text. Use ‘*’ or ‘-’ for bullet points where necessary.”

I also added my personal part in Italian after this sentence. If you put it before, it doesn’t work.

You can try adding \n\n at the beginning and end of your prompt, as some users have found this helps force plain text output. Another option is explicitly stating, “Respond with no Markdown, no asterisks, no backticks, and no special formatting—just plain text.” If that still doesn’t work, you might consider using a simple find-and-replace tool to strip Markdown characters automatically.

As noted in my own thread, I have had similar problems, but with emojis. I don’t really mind Markdown itself all that much. I would truthfully prefer bare text, because it is more efficient in terms of tokens, but Markdown is not laborious to remove.

GPT4’s default (non-end user controllable) generation settings are problematic in my opinion. There seems to be a high weight given for both emojis and Markdown format. I believe that the default should be for plain ASCII, with Markdown and UTF8 special characters being optional. This would allow both serious work, and teenage material where appropriate.