Skip to main content

Text case converter API

Convert text to UPPERCASE, lowercase, Title Case, or Sentence case.

EndpointPOST https://astraltext.com/api/v1/smart-case-converter
AuthBearer token, free
Sendsinput: text
Returnsresult: text
optionsentence | title | uppercase | lowercase
PriceFree. 1,000 calls a day, 60 a minute.

When to call it

Headings, product names and imported records arrive in whatever case somebody typed. Normalising in code is what makes a catalogue look deliberate, and it is the only way to apply the same rule to ten thousand rows.

For a one-off, the browser version needs no token and never sends your data anywhere: it runs on your own machine.

Example

curl
curl -X POST https://astraltext.com/api/v1/smart-case-converter \
  -H "Authorization: Bearer ast_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input": "état du marché. voilà tout.", "option": "title"}'
response
{
  "tool": "smart-case-converter",
  "result": "État Du Marché. Voilà Tout.",
  "chars": 27,
  "ms": 2
}

In your language

JavaScript
const res = await fetch("https://astraltext.com/api/v1/smart-case-converter", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ASTRAL_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"input": "état du marché. voilà tout.", "option": "title"}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const { result } = await res.json();
Python
import os, requests

res = requests.post(
    "https://astraltext.com/api/v1/smart-case-converter",
    headers={"Authorization": f"Bearer {os.environ['ASTRAL_TOKEN']}"},
    json={"input": "état du marché. voilà tout.", "option": "title"},
    timeout=30,
)
res.raise_for_status()
result = res.json()["result"]

Parameters

FieldTypeNotes
inputstringRequired. Up to 200,000 characters per call.
optionstringOne of: sentence, title, uppercase, lowercase.

Errors

Errors are RFC 7807 problem documents with a stable type you can branch on.

missing-token401No Authorization header.
bad-request400input missing or the wrong type.
bad-option400option is not one of the listed values.
tool-failed422The input could not be processed. detail says why.
quota-exceeded429Past 1,000 calls today.

Questions

Which cases can I ask for?
Send "option" as sentence (the default), title, uppercase or lowercase. Anything else is refused with a bad-option error.
Are accented letters handled?
Yes. The letter classes are Unicode-aware, so a word starting with an accented character is capitalised correctly rather than being left alone or mangled.
How is sentence case decided?
The text is lowercased, then the first letter of the string and the first letter after a full stop, question mark or exclamation mark is capitalised.

Other endpoints

A token takes thirty seconds

Free, no card, 1,000 calls a day, and the same token works on astraltext.com, astralpdf.com, astraljson.com and astralbatch.com.

Get a free token