Remove line breaks API
Unwrap text that was hard-wrapped into short lines, keeping the blank lines that separate paragraphs.
| Endpoint | POST https://astraltext.com/api/v1/remove-line-breaks |
| Auth | Bearer token, free |
| Sends | input: text |
| Returns | result: text |
| Price | Free. 1,000 calls a day, 60 a minute. |
When to call it
Text copied out of a PDF, an email client or a terminal arrives wrapped at whatever width it was displayed in. Those breaks are not in the writing, they are in the rendering, and they have to go before the text can be reflowed, stored in a single field or sent to a model.
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/remove-line-breaks \
-H "Authorization: Bearer ast_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"input": "A sentence that was\nwrapped by the viewer.\n\nA second paragraph\nwrapped the same way."}'response
{
"tool": "remove-line-breaks",
"result": "A sentence that was wrapped by the viewer.\n\nA second paragraph wrapped the same way.",
"chars": 84,
"ms": 1
}In your language
JavaScript
const res = await fetch("https://astraltext.com/api/v1/remove-line-breaks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ASTRAL_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"input": "A sentence that was\nwrapped by the viewer.\n\nA second paragraph\nwrapped the same way."}),
});
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/remove-line-breaks",
headers={"Authorization": f"Bearer {os.environ['ASTRAL_TOKEN']}"},
json={"input": "A sentence that was\nwrapped by the viewer.\n\nA second paragraph\nwrapped the same way."},
timeout=30,
)
res.raise_for_status()
result = res.json()["result"]Parameters
| Field | Type | Notes |
|---|---|---|
| input | string | Required. Up to 200,000 characters per call. |
Errors
Errors are RFC 7807 problem documents with a stable type you can branch on.
| missing-token | 401 | No Authorization header. |
| bad-request | 400 | input missing or the wrong type. |
| tool-failed | 422 | The input could not be processed. detail says why. |
| quota-exceeded | 429 | Past 1,000 calls today. |
Questions
- Does it destroy paragraphs?
- No. A blank line between two blocks is a paragraph break and is kept. Only the breaks inside a paragraph are joined.
- Are Windows line endings handled?
- Yes. Carriage return, line feed and the pair are all treated the same, so text from any platform behaves identically.
- What replaces the removed break?
- A single space, so the words on either side do not run together. Runs of whitespace around the join are collapsed to that one space.
Other endpoints
- AI text cleaner API
- Remove em dashes API
- Remove invisible characters API
- Remove emoji API
- Strip Markdown API
- Remove citations API
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