Detect the language of any code via a free API
No API needed, no rate limits, no restrictions.
Detection runs against the live API.
Run a detection to see the result.
Coverage
Detects 54 languages
Reference
The API in 30 seconds
Base URL https://api.langhint.com. Send the raw source code as the request body, get JSON back. No
authentication required; CORS is open, so you can call it from the browser.
POST
/detectClassify a source code string and return the most likely language plus alternatives.
Request body
The raw source code (Content-Type: text/plain) — required, must be
non-empty. No JSON wrapper, no escaping.
Query parameters
| Name | Type | Description | |
|---|---|---|---|
| max_candidates | number | optional | Maximum number of candidates to return, 1–10. Defaults to 3. |
Request
curl -X POST "https://api.langhint.com/detect?max_candidates=3" \ --data-binary 'SELECT id, name FROM users WHERE active = 1'
curl --data-binary @query.sql \ "https://api.langhint.com/detect?max_candidates=3"
Example response
# 200 OK { "language": "sql", // most likely language (lowercase id) "probability": 0.97, // probability of the top result (0–1) "candidates": [ // up to max_candidates, sorted desc { "language": "sql", "probability": 0.97 }, { "language": "ini", "probability": 0.01 } ] }
Status codes
- 200 — language detected, body as above
- 400 — request body is empty
- 422 — validation failed (e.g.
max_candidatesout of range)
GET
/healthLiveness probe for monitoring and uptime checks. Takes no parameters.
# 200 OK { "status": "ok" }
GET
/docsInteractive OpenAPI (Swagger) documentation, auto-generated from the service — open /docs ↗.