Prompt Engineering: Writing Prompts That Get Better AI Results

AI2026-09-23TryQuickToolBox

Why Your AI Prompts Aren't Working

You've probably tried asking an AI for help—writing an email, debugging code, summarizing an article—and gotten a response that missed the mark. It might have been too vague, too long, or completely off-topic. The problem usually isn't the AI; it's the prompt.

Prompt engineering is the practice of designing inputs to get better outputs from large language models (LLMs). It's not about magic words; it's about clear communication. This guide gives you practical techniques to write prompts that consistently produce useful results.

1. Be Specific and Clear

LLMs are not mind readers. If you ask "Write about dogs," you'll get a generic essay. Instead, specify the topic, format, length, and audience.

Bad: Write about dogs.
Good: Write a 300-word article for pet owners about the top 3 dog breeds for apartments. Include exercise needs and temperament.

The more constraints you provide, the more focused the output. Think of it as giving instructions to a freelancer: the clearer you are, the better the result.

2. Provide Context and Examples

LLMs learn from the context you give them. If you want a specific style or format, show an example.

Example: Summarize the following customer review in one sentence, focusing on the main complaint. Example: "The product arrived late and was damaged." Review: "I ordered this on the 5th, it shipped on the 10th, and when it finally arrived, the box was crushed and the item was scratched."

This technique, called "few-shot prompting," helps the model understand the pattern you want.

3. Use Role-Playing

Assigning a role to the AI can improve the quality and tone of the response. For example, "Act as a senior software engineer" or "You are a friendly customer support agent." This primes the model to adopt a specific perspective and expertise level.

Example: Act as a cybersecurity expert. Explain the risks of SQL injection to a non-technical manager in under 200 words.

4. Break Complex Tasks into Steps

If your request is complex, break it into smaller, sequential prompts. This reduces the chance of the model getting overwhelmed or missing details.

Instead of: Create a marketing plan for a new app.
Try: Step 1: Identify the target audience for a productivity app aimed at remote workers. Step 2: List three key features that would appeal to them. Step 3: Suggest two marketing channels to reach them.

You can also ask the model to "think step by step" to encourage reasoning.

5. Specify the Output Format

If you need the output in a particular format—JSON, Markdown, a table—say so explicitly. This is especially useful when integrating AI into automated workflows.

Example: Extract the product name, price, and rating from the review below. Return the result as a JSON object with keys: name, price, rating.

For developers, tools like JSON Formatter can help validate and format the AI's output.

6. Iterate and Refine

Rarely will the first prompt be perfect. Treat it as a conversation: review the output, identify what's missing, and adjust your prompt accordingly.

Example: If the AI's summary is too long, follow up with: Make it shorter—under 50 words. If it's too technical, say: Explain it as if I'm a beginner.

7. Avoid Ambiguity and Negations

LLMs sometimes struggle with negations. Instead of saying "Don't use jargon," say "Use simple language." Instead of "Don't be vague," say "Be specific and include examples."

8. Experiment with Temperature and Parameters

If you're using an API, you can adjust parameters like temperature (creativity) and max_tokens (length). Lower temperature (e.g., 0.2) gives more deterministic, focused outputs; higher (e.g., 0.8) encourages creativity. For factual tasks, use low temperature.

Comparison: Weak vs. Strong Prompts

Weak PromptStrong Prompt
Write a blog post.Write a 500-word blog post for small business owners about the benefits of cloud accounting software. Include 3 key advantages and a call to action.
Fix this code.Debug this Python function that calculates Fibonacci numbers. Explain the error and provide a corrected version with comments.
Summarize this.Summarize the following article in 3 bullet points, each under 20 words, focusing on the main argument.

FAQ

What is prompt engineering?

Prompt engineering is the process of designing and refining inputs (prompts) to guide large language models toward generating desired outputs. It involves clarity, context, and iteration.

Do I need to be a programmer to write good prompts?

No. While some techniques like API parameter tuning require coding, most prompt engineering is about clear communication and can be done by anyone using chat interfaces.

How can I improve my prompts quickly?

Start by being specific: state the format, length, and audience. Provide examples if possible. Then iterate—if the output isn't right, tell the AI what to change.

Ready to put these techniques into practice? If you're working with AI-generated JSON, use our JSON Formatter to validate and pretty-print the output for your applications.