Did you know ChatGPT can format responses?
By default ChatGPT formats responses in markdown format. You can prompt ChatGPT to respond in formats other than Markdown. Here are some approaches you can use:
1. Specify the desired format explicitly in your prompt:
For example:
– “Provide your response in HTML format.”
– “Format your answer as a JSON object.”
– “Give me the response in plain text without any formatting.”
2. Provide an example of the desired format:
For instance:
“List the top 5 largest countries by area. Format your response like this example:
- Country name – Area in km²
”
3. Use specific instructions for data structures:
“List the 3 most populous cities in the world. Return the data as a JavaScript array of objects, where each object has ‘city’ and ‘population’ properties.”
4. Request a specific output structure:
“Explain the water cycle in 3 steps. Format each step as follows:
STEP NUMBER: Step name
DESCRIPTION: Step description”
5. Ask for tabular data in a specific format:
“Show me the nutritional information for an apple. Present it as an HTML table with ‘Nutrient’ and ‘Amount’ columns.”
6. Request code snippets in a specific language:
“Write a function to calculate the factorial of a number. Provide the code in Python without any Markdown formatting.”
Remember that while ChatGPT will try to follow your formatting instructions, it may not always be perfect. You might need to refine your prompt or post-process the output to get exactly the format you need.
If you’re using the ChatGPT API, you have additional options like using the `functions` parameter to define a specific output structure, or setting the `response_format` parameter to request JSON output.
Thx to Jarrod Brake for asking!