ForHosting KIT · Text & AI

Parentheses / brackets balance checker

Paste text and find out whether every (, [ and { closes in the right order: (a[b]) is balanced, with a maximum depth of 2. When something is off, you get the position of the first error. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
(a[b])
You get
Max depth
2

Check whether parentheses, brackets and braces are balanced. Search intent: parentheses checker / balanced brackets. No network calls, no random seeds, and no server state are required for a correct answer.

How balance is checked

The tool reads the text from beginning to end and keeps track of every opening parenthesis, square bracket and curly brace it meets. Each closing sign must match the most recent one still open, of the same kind; when it does, that pair is settled and the reading continues. The text is balanced when every opening has found its partner and nothing is left open at the end. Along the way, the tool notes the deepest level of nesting it reaches: in (a[b]) the square brackets sit inside the parentheses, so the maximum depth is 2. Letters, numbers and any other characters are skipped.

Finding the first problem

When the text is not balanced, you get the position of the first error, so you can go straight to the bracket that breaks the pattern instead of counting by hand. That helps with formulas, nested lists, notes full of side remarks or any text where one stray sign changes the meaning. The check runs entirely in your browser, without network calls, random elements or stored state, so the same text always gives the same answer, however many times you run it.

How it works

Check whether parentheses, brackets and braces are balanced. Stack scan reports max depth and first error index. The implementation is pure JavaScript with no external services.

No network calls, no random seeds, and no server state are required for a correct answer. Failed jobs are not billed. Landings target the stated search intent with precise keywords.

Prefer explicit units and ranges over silent coercion of bad types. When a field is optional, defaults are documented in params and echoed in the output.

When to use it

Use this when your search intent matches the calculator name and you need a reproducible answer for teaching, finance ops, GIS, text tooling, or unit history work. Check whether parentheses, brackets and braces are balanced. No network calls, no random seeds, and no server state are required for a correct answer.

Failed jobs are not billed. Landings target the stated search intent with precise keywords. Prefer explicit units and ranges over silent coercion of bad types.

When a field is optional, defaults are documented in params

Does it call the network?

No. All math and text transforms are local and deterministic.

What does it mean for brackets to be balanced?

Every opening parenthesis, square bracket or curly brace has a closing sign of the same kind, and they close in the reverse order they were opened. Equal counts of opening and closing signs are not enough if the order does not fit.

What does the maximum depth tell me?

How many levels of nesting there are at the deepest point of the text. In (a[b]) the square brackets sit inside the parentheses, so the maximum depth is 2.

How do I find where the error is?

When the text is not balanced, the tool gives you the position of the first error. Go straight to that sign instead of counting brackets by hand, and check the rest again once it is fixed.

Do letters and other characters affect the result?

No. Only the three kinds of brackets are counted. Letters such as the a and b in (a[b]), numbers and any other symbols are skipped and never change the answer.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/text/paren-balance

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/text/paren-balance \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"(a[b]{c})"}'
{
  "text": "(a[b]{c})"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "text.paren_balance",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

The calculator is free in the browser, deterministic, and identical in the API path. Inputs are validated before any arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE results when decimals are requested. Use the same JSON contract from spreadsheets, CMS hooks, automation,

How it works

The calculator is free in the browser, deterministic, and identical in the API path. Inputs are validated before any arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE results when decimals are requested. Use the same JSON contract from spreadsheets, CMS hooks, automation, or teaching demos.

Inputs, limits and rounding

Optional decimals use half-up once. No network calls, no random seeds, and no server state are required for a correct answer. Failed jobs are not billed. Landings target the stated search intent with precise keywords. Prefer explicit units and ranges over silent coercion of bad types. When Provide the required parameters as JSON numbers or strings as documented. Invalid types, missing required fields, or out-of-range values raise invalid_input with a clear message. Outputs echo key inputs so automation can log the full context of each call. The calculator is free in the browser, deterministic, and identical in the API path. Inputs are validated before any arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE results when decimals are requested. Use the same JSON contract from spreadsheets, CMS hooks, automation, or teaching demos.

When to use it

The calculator is free in the browser, deterministic, and identical in the API path. Inputs are validated before any arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE results when decimals are requested. Use the same JSON contract from spreadsheets, CMS hooks, automation, or teaching demos.

Quick check

Paste values in the free widget and compare with a spreadsheet.

Automation

Call the API with the same JSON contract from n8n, scripts, or CMS.

Teaching

Show the formula and pinned golden examples without proprietary software.

Is it free in the browser?

Yes. Tier A runs fully client-side with the same core as the API.

What happens on bad input?

The handler throws invalid_input; failed jobs are not billed.

Can I use it from the API?

Yes. Send the same JSON fields documented in params.

Who authors this?

Aspire (elon@forhosting.com), EN-only delivery; Nitro hydrates locales.

Read the full KIT documentation →