Chat Messages Validator (OpenAI / Chat Completions format)
Validate a Chat Completions messages array before you send it — checks roles (system/user/assistant/tool), required content, and common mistakes that cause a 400. 100% local.
Last updated:
CommentsPaste your Chat Completions messages array above and it's validated instantly — bad roles, missing content, and structural mistakes are flagged by message index before you send the request. Everything runs in your browser.
Valid — 4 messages.
1 system · 2 user · 1 assistant
Validation runs entirely in your browser. Checks roles (system / user / assistant / tool / function), required content, and common structural mistakes before you send to the API.
What is Chat Messages Validator?
The messages array is the core of every Chat Completions request: an ordered list of { role, content } objects where role is system, user, assistant, tool, or function. Small mistakes — a typo'd role, a message with no content, a tool response missing its tool_call_id, or the whole payload not being an array — all return a 400 invalid_request_error, often with a vague message. This validator parses your array locally, checks each message against the format rules, and tells you exactly which index is wrong, so you fix it before spending a round-trip on the API.
How to validate a messages array
- 1Paste your messages array as JSON.
- 2Read the result: green means valid with a per-role count.
- 3Fix any flagged message (the index and reason are shown).
Key Concepts
- Role
- system / user / assistant / tool / function — who each message is from.
- tool_call_id
- Links a tool result message back to the assistant's tool call.
Frequently Asked Questions
What roles are allowed in a messages array?
system, user, assistant, tool, and function. This validator flags any unknown role, which is a common cause of a 400 invalid_request_error.
Why does my messages array return a 400?
The usual culprits are a missing content field, an unknown role, a message that isn't an object, or a tool message missing its tool_call_id. The validator points to the exact message index.
Is my data uploaded?
No. Validation runs entirely in your browser; the messages never leave your device.
Try Next
Text Chunker
Split long text into overlapping chunks for embedding and RAG pipelines. Preview recursive, paragraph, sentence, or fixed strategies with live token counts. Runs 100% in your browser.
Related Tools
Prompt Token Breakdown
Break a prompt into segments and see how many tokens — and how much cost — each part uses. Find the heaviest section (system, few-shot examples, or user input) so you know exactly what to trim. 100% local.
Schema → Tool Definition
Turn a sample JSON payload into function-calling / tool definitions for OpenAI, Anthropic, and Gemini — side by side. Strict-mode toggle adds required + additionalProperties: false. 100% local, paste straight into your tools array.
Prompt Template Tester
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Prompt Diff
Compare two versions of a prompt line by line and see the token delta between them — so you know exactly what changed and whether an edit made the prompt cheaper or more expensive. 100% local.
Embedding Cost Calculator
Estimate the cost of embedding a corpus — pick a model, enter the number of documents and average tokens each, and get the total token count and dollar cost. 100% local.
Vector Storage Calculator
Estimate how much memory or disk your embeddings need — enter vector count, dimensions, and precision (float32/float16/int8/binary) to see raw and indexed size. 100% local.