DevKits

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:

Comments

Paste 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.

258 chars · 6 lines

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

  1. 1Paste your messages array as JSON.
  2. 2Read the result: green means valid with a per-role count.
  3. 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

Reference & Guides