ForHosting KIT · Text & AI

Pad a string on the right to a fixed length

Extend text on the right to an exact length: Item padded to 10 with dots becomes Item......, with 6 dots added. Your text is never shortened, and a plain space is used when you pick no character. 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
Item
Target length
10
Character
.
You get
Result
Item......
Original length
4
Padding added
6

Right padding extends text to an exact character length by appending a chosen character after the original value. It is a small operation with a surprisingly important role in fixed-width exports, readable console reports, labels, identifiers, and legacy integrations. Enter the text, choose the total target length, and optionally select one fill character. The original content is never shortened or replaced.

Choose the target length and padding character

Start with the text exactly as it should appear at the beginning of the result. For example, text Item has four characters. A target length of ten leaves six positions to fill on the right.

If character is a hyphen, the result becomes Item followed by six hyphens. When character is omitted, a normal space is used, which is usually the correct choice for aligned plain-text columns and fixed-width records. The fill value must be exactly one Unicode character; accepting a single character keeps the requested length unambiguous and ensures every added unit occupies one logical character position.

The tool counts Unicode code points, so an emoji can serve as one padding character and non-ASCII text is measured more naturally than by raw UTF-16 storage units. Keep in mind that visual terminal width can still differ for combining marks and wide East Asian glyphs. This capability promises character length, not a font-dependent pixel width.

Use a monospaced font and simple fill characters when visual column alignment is the primary goal.

Understand validation and the returned fields

The operation never truncates input. The target length must be a non-negative integer at least as large as the text's current character count. The maximum target length is one hundred thousand characters, a practical boundary that keeps memory and response sizes controlled.

The character field confirms the fill used, including the default space. Empty text is valid and can create a line made entirely from the selected character. Invalid types, fractional lengths, oversized targets, and empty or multi-character fill strings are rejected clearly.

These rules make the response safe to use as a deterministic formatting primitive in automated pipelines.

Build aligned fixed-width output reliably

Right padding is most useful when values begin at a shared left edge and every field must reserve the same amount of space. To build a small report, determine a width for each textual column, run every cell through this capability with a space character, and concatenate the results with any separators your format requires. Short labels gain trailing spaces while labels already at the chosen width remain unchanged.

Fixed-width files use the same pattern, but their specification may require a visible fill such as zero, a period, or an underscore. Validate your source data before padding so no value exceeds its assigned field length; this tool will surface that mismatch as an error rather than make a destructive choice. If you need left padding, centering, truncation, line wrapping, or display-cell-aware terminal layout, use a purpose-built operation for that separate formatting rule.

Align readable text columns

Append spaces to short labels so the next column starts at a consistent position in monospaced reports and logs.

Create fixed-width export fields

Extend text fields to the exact lengths required by legacy file layouts without truncating values that are too long.

Which character is used by default?

A single space is used when character is omitted.

Can I use an emoji as the padding character?

Yes. The fill may be any one Unicode code point, although its visual width depends on the font and display.

What happens if my text is already longer than the target length?

Nothing is cut. The tool stops and tells you, because silently dropping the last characters could corrupt an export or an identifier. If both lengths are equal, the text comes back unchanged.

Does the target length include my original text?

Yes. It is the total length of the finished result. Item has four characters, so a target of 10 leaves six positions, and those six are filled on the right.

Will padded columns line up with Japanese text or emoji?

Not always. The tool counts characters, not the width they take on screen, so wide East Asian characters and combining marks can still shift a column. Use a monospaced font and simple fill characters.

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/str/pad-right

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/str/pad-right \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Item","target_length":10}'
{
  "text": "Item",
  "target_length": 10
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.pad_right",
  "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.

If it already has the requested length, the result is unchanged; if it is longer, validation stops the request instead of discarding information. The same deterministic algorithm powers browser and API use, making repeated formatting predictable.

Choose the target length and padding character

Then set target_length to the complete character length you need, including both the original text and all appended padding.

Understand validation and the returned fields

If text is eight characters and the requested target is six, the request returns invalid_input rather than silently removing the last two characters. This is important in exports and identifiers, where an apparently convenient formatting step must not corrupt real data. On success, result contains the completed string, original_length reports the measured size before padding, target_length repeats the validated requested size, and padding_added tells you exactly how many characters were appended. If the original and target lengths are equal, padding_added is zero and result is identical to text.

Build aligned fixed-width output reliably

For batch generation, call the API once for each item at the published base price of $0.002, or run the browser tool for interactive formatting. Because the algorithm uses no network, randomness, locale rules, or current time, an identical request always returns identical JSON.

Generate stable test fixtures

Produce deterministic padded values for snapshots, parser tests, and examples that must remain byte-for-byte repeatable.

What happens when the text is already the target length?

The text is returned unchanged and padding_added is zero.

Does the tool shorten text that is too long?

No. It returns invalid_input when target_length is smaller than the current text length.

How much does an API request cost?

Each successful API request uses the published base price of $0.002.

Read the full KIT documentation →