Docs/APIs/Unicode Escape/Unescape

Unicode Escape/Unescape

Escape and unescape Unicode characters

OperationalCredits 1 per callp50 175msData ConversionStar

Overview

The `escape` action walks the input by code point and writes every character, including plain ASCII letters and spaces, as `\u` followed by four upper-case hex digits. A character above U+FFFF, such as most emoji, is written as its UTF-16 surrogate pair, two `\uXXXX` sequences in a row, so 😀 becomes `\uD83D\uDE00`. `character_count` counts code points, so that emoji counts as one. `unicode_points` lists each character with `char`, its escape in `unicode` (the full pair for astral characters) and its `codepoint` in `U+` form, such as `U+1F600`.

The `unescape` action recognises three forms: `\uXXXX` with exactly four hex digits, the braced `\u{1F600}` form with one to six digits, and `\xXX` with two. Anything else, including other backslash escapes like `\n`, is left as literal text. A braced value above U+10FFFF returns a 400. Surrogate pairs written as two `\uXXXX` sequences recombine into the original character. The response holds the result in `unescaped`, and `character_count` there is the JavaScript string length, which counts an emoji as two.

Any `action` other than `escape` is treated as unescape. The `unicode_points` breakdown is only produced by escape, and it is null on the Free plan.

Live Test Unicode Escape/Unescape API →

Endpoint

One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.

POSThttps://api.apiverve.com/v1/unicodeescape
curl -X POST https://api.apiverve.com/v1/unicodeescape \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Hello World",
  "action": "escape"
}'

Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.

Authentication

Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.

401 is the only auth verdict

A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.

Parameters

Sent as JSON in the request body. Premium parameters are accepted on every plan but only take effect on plans that include them.

ParameterTypeDescription
textRequiredstringThe text to escape
actionOptionalstringThe action to perform
escapeunescape
default escape

Response

Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.

Sample response
{
  "status": "ok",
  "error": null,
  "data": {
    "action": "escape",
    "original": "Hello World",
    "escaped": "\\u0048\\u0065\\u006C\\u006C\\u006F\\u0020\\u0057\\u006F\\u0072\\u006C\\u0064",
    "character_count": 11,
    "unicode_points": [
      {
        "char": "H",
        "unicode": "\\u0048",
        "codepoint": "U+0048"
      },
      {
        "char": "e",
        "unicode": "\\u0065",
        "codepoint": "U+0065"
      },
      {
        "char": "l",
        "unicode": "\\u006C",
        "codepoint": "U+006C"
      },
      {
        "char": "l",
        "unicode": "\\u006C",
        "codepoint": "U+006C"
      },
      {
        "char": "o",
        "unicode": "\\u006F",
        "codepoint": "U+006F"
      },
      {
        "char": " ",
        "unicode": "\\u0020",
        "codepoint": "U+0020"
      },
      {
        "char": "W",
        "unicode": "\\u0057",
        "codepoint": "U+0057"
      },
      {
        "char": "o",
        "unicode": "\\u006F",
        "codepoint": "U+006F"
      },
      {
        "char": "r",
        "unicode": "\\u0072",
        "codepoint": "U+0072"
      },
      {
        "char": "l",
        "unicode": "\\u006C",
        "codepoint": "U+006C"
      },
      {
        "char": "d",
        "unicode": "\\u0064",
        "codepoint": "U+0064"
      }
    ]
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
actionstring"escape"The action performed on the text (escape or unescape)
originalstring"Hello World"The original input text with escape sequences
escapedstring"\u0048\u0065\u006C\u006C\u006F\u0020\u0057\u006F\u0072\u006C\u0064"The converted text with escape sequences applied or removed
character_countnumber11Total number of characters in the result text
unicode_pointsPremiumarray[11]Array of character data with Unicode escape sequences
charPremiumstring"H"Individual character from the converted text
unicodePremiumstring"\u0048"Unicode escape sequence representation of the character
codepointPremiumstring"U+0048"Unicode codepoint notation (e.g., U+0048) for the character

Errors

Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead error to tell them apart; see rate limits.

Use cases

JSON Processing
Escape Unicode characters in JSON strings for safe transmission and storage
Code Generation
Generate Unicode escape sequences for use in source code, configuration files, or string literals
Data Migration
Convert Unicode characters to escape sequences when migrating between systems with different encoding support
Debugging
View Unicode escape sequences of characters to debug encoding issues and identify problematic characters

Other ways to use Unicode Escape/Unescape

Set up Unicode Escape/Unescape on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.

Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →
Google Sheets or ExcelA =VERVE() formula fills a column — no script, no export, recalculates in place.VerveSheets →Reference →

More in Data Conversion:

Was this page helpful?