Some days ago I posted on LinkedIn the result of a free-time experiment related to use AI for generating videos based on prompts. This was the funny result:
In the comments of that post, I’ve also posted the screenshot of a complex JSON I’ve used as a prompt for the AI model:
The goal of that funny post was simply to show how with AI today can be possible to generate incredible and realistic videos. But that prompt generates more questions than the video itself…
JSON prompting has emerged as a powerful technique for improving AI model performance and reliability. By structuring prompts with JSON formatting, developers can achieve more consistent, predictable, and controllable AI responses.
JSON prompting involves formatting prompts using JSON structure to provide clear instructions, context, and constraints to AI models. Instead of free-form text, the prompt follows a structured format that helps the AI understand exactly what is expected.
In more simple words, JSON prompting is just putting your prompt inside a structured format, without lexical peculiarities of text format or any vibes:
{
"task":"summarize this article",
"audience":"Financial Manager",
"length":"500 words",
"tone":"professional"
}
LLMs don’t “understand” language the way we do, but they follow patterns and structure. JSON is a structured format that leaves no ambiguity to LLMs (they don’t have to guess what you mean but you’re telling them exactly what you want).
By providing explicit constraints and output formats, JSON prompting helps minimize AI hallucinations and ensures responses stay within defined boundaries. JSON structure also provides clear separation between different types of information, helping AI models understand the context more effectively. JSON prompting also ensures AI responses follow a consistent, predictable format that’s easy to parse and process programmatically.
You can do by yourself a simple test with any LLMs you have.
Example:
Text Prompt: write a post for twitter about Dynamics 365 Business Central, with maximum lenght of 200 characters. The post need to contain a question for readers.
Result:
Unlock your business potential with Dynamics 365 Business Central! Streamline operations, boost productivity, and gain real-time insights.Question for you: What’s the biggest challenge your business faces with financial management and operations?#Dynamics365 #BusinessCentral #ERP #Productivity
JSON prompt (guiding structure):
{
"task":"write social post",
"platform":"twitter",
"structure":{
"hook":"short, punchy, curiosity-driven",
"point":"3-5 insights, each 2-3 sentences",
"action":"one question to spark replies"
},
"topic":"Dynamics 365 Business Central",
"tone":"casual and smart",
"max-length":200
}
Result:
Hook: Ever wonder why some businesses seem to run like clockwork while others are constantly putting out fires?
Point: Dynamics 365 Business Central is the secret weapon. It’s not just another ERP system—it’s your business’s command center that connects everything from sales to inventory to financials in real-time.The beauty? It grows with you. Start simple, add complexity as you need it. No more expensive customizations that break when you upgrade.Plus, it’s cloud-native, so your team can work from anywhere. No more VPN headaches or server maintenance nightmares.
Action: What’s the biggest pain point in your current business processes that you wish you could automate?
As you can see, with JSON prompting it’s very easy to drive the generation of the response structure.
Let’s do another example. Here I’m asking to Cursor to generate AL code with a text prompt:
create an AL procedure that calculates the total amount of sales orders for customers where country region is IT
Result contains text and AL code:
Now I’m using a JSON prompt like the following:
{
"task": "write procedure",
"language": "AL",
"goal": "create a procedure that calculates the total amount of sales orders for customers where country region is IT",
"constraints": ["procedure must return a decimal value", "include comments"],
"output_format": "code only, no explanation"
}
Response:
JSON prompting also enables complex multi-step reasoning by breaking down tasks into structured components.
Simply because LLMs are trained on code, documents, APIs and structured data and JSON looks like the stuff they were fed. The less they have to guess, the better the result you have.
Traditional text prompting is hard to parse and prone to errors. JSON prompting is structured, easy to parse and gives reliable results.
P.S. here I’m talking about JSON but also YAML and XML formats are good for prompting.
And now the inevitable question:
NO!
While JSON prompting is powerful, it’s not always the best choice.
JSON prompting is good for:
JSON prompting is not good for:
In conclusion: No, you shouldn’t always write prompts in JSON. The choice depends on your specific use case:
The key is matching the prompt style to your task requirements. Start with natural language for simple tasks, and graduate to JSON when you need structure, consistency, or system integration.
Remember: The goal is to get the best results for your specific use case, not to follow a one-size-fits-all approach!
Original Post https://demiliani.com/2025/08/07/json-prompting-in-ai-why/