Prompt Engineering Course
Formatting Best Practices
Formatting is one of the most underestimated aspects of prompt engineering.
Even when instructions are correct, poor formatting can confuse the model, produce inconsistent outputs, or break downstream systems.
Formatting best practices focus on structuring prompts so that models clearly understand boundaries, hierarchy, and expectations.
Why Formatting Matters to Language Models
Language models do not see prompts as visual layouts.
They see sequences of tokens where structure signals meaning.
Proper formatting helps the model:
- Identify instructions vs data
- Recognize input-output boundaries
- Maintain consistency across responses
In production systems, formatting often matters more than wording.
Unformatted vs Structured Prompt
Consider this loosely formatted prompt.
Analyze this text and summarize it highlight key points and give recommendations.
Text: The application has frequent outages and users are unhappy.
This prompt mixes instructions and data.
Now compare it with a structured version.
Task:
Analyze the following text.
Steps:
1. Summarize the text.
2. Highlight key issues.
3. Provide recommendations.
Input Text:
The application has frequent outages and users are unhappy.
The second prompt clearly separates intent, steps, and input.
Use Clear Section Headers
Section headers act as anchors for the model.
Common headers used in professional prompts include:
- Task
- Instructions
- Input
- Output Format
- Constraints
These headers help the model understand what each part represents.
Bullet Points vs Paragraphs
Bullet points are useful when:
- Listing steps
- Defining constraints
- Specifying options
Paragraphs work better for:
- Context descriptions
- Background information
- Explanations
Mixing both improves clarity.
Explicit Output Formatting
Never assume the model knows how you want the output formatted.
Always specify output structure explicitly.
Output Format:
- Summary:
- Issues:
- Recommendations:
This reduces variation and makes outputs easier to parse.
Delimiters and Boundaries
Delimiters help the model distinguish between instructions and data.
Common delimiters include:
- Triple backticks
- Quotes
- Explicit labels
Example using delimiters:
Input Text:
"""
The application has frequent outages and users are unhappy.
"""
This clearly signals the data boundary.
Formatting for Machine Consumption
When prompts feed into code or pipelines, formatting becomes critical.
Structured outputs such as JSON or tables must be enforced.
Return the result strictly in JSON with keys:
- summary
- issues
- recommendations
This enables reliable automation.
How Learners Should Practice Formatting
To build formatting skill:
- Rewrite messy prompts into structured sections
- Add headers and delimiters
- Compare output consistency
- Test small formatting changes
Formatting is a controllable variable — use it deliberately.
Common Formatting Mistakes
Avoid:
- Long unbroken paragraphs
- Mixing instructions and input
- Unspecified output formats
These mistakes cause unpredictable outputs.
Practice
What does good formatting primarily provide to prompts?
Why are delimiters used in prompts?
Explicit output formatting improves what?
Quick Quiz
Formatting primarily helps models understand:
Why specify output formats?
Section headers in prompts act as:
Recap: Formatting controls clarity, boundaries, and output consistency in prompts.
Next up: Avoiding hallucinations and keeping model responses grounded.