POST인코딩
텍스트나 바이트를 Base64로 바꿉니다. 표준 또는 URL-safe 알파벳, 패딩 유무, 줄 바꿈을 고를 수 있습니다.
POST
https://api.base64hub.com/v1/encode요청
input에 텍스트를 담은 JSON을 보내세요. 텍스트는 UTF-8로 인코딩됩니다.
curl -s https://api.base64hub.com/v1/encode \
-H 'Content-Type: application/json' \
-d '{"input": "Hello, hub!"}'
const res = await fetch("https://api.base64hub.com/v1/encode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: "Hello, hub!" }),
});
const { output } = await res.json();
console.log(output); // SGVsbG8sIGh1YiE=
import json
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/encode",
data=json.dumps({"input": "Hello, hub!"}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as res:
print(json.load(res)["output"]) # SGVsbG8sIGh1YiE=
b64 "Hello, hub!"
# SGVsbG8sIGh1YiE=
본문 매개변수
| 이름 | 타입 | 설명 |
|---|---|---|
input 필수 | string | 인코딩할 텍스트. 먼저 UTF-8 바이트로 변환됩니다. |
variant 선택 | "standard" 또는 "url" | 알파벳. url은 +와 / 대신 -와 _를 씁니다. 기본값은 "standard". |
padding 선택 | boolean | 끝의 =를 유지합니다. 기본값은 true. |
wrap 선택 | integer, 0~1000 | 출력 N자마다 \n을 넣고 끝에는 넣지 않습니다. 76은 MIME. 기본값은 0으로 줄 바꿈 없음. |
그 밖의 필드는 400 invalid_body로 거부합니다.
원시 바이트
파일이나 바이너리 데이터를 인코딩하려면 바이트를 application/octet-stream으로 보내세요. 이때 옵션은 쿼리 문자열로 보냅니다(variant=url, padding=false, wrap=76).
printf '\xfb\xff\xbf' | curl -s \
'https://api.base64hub.com/v1/encode?variant=url&padding=false' \
-H 'Content-Type: application/octet-stream' \
--data-binary @-
const bytes = new Uint8Array([0xfb, 0xff, 0xbf]);
const res = await fetch(
"https://api.base64hub.com/v1/encode?variant=url&padding=false",
{ method: "POST", headers: { "Content-Type": "application/octet-stream" }, body: bytes },
);
console.log((await res.json()).output); // -_-_
import json
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/encode?variant=url&padding=false",
data=b"\xfb\xff\xbf",
headers={"Content-Type": "application/octet-stream"},
)
with urllib.request.urlopen(req) as res:
print(json.load(res)["output"]) # -_-_
printf '\xfb\xff\xbf' | b64 --url --no-pad
# -_-_
본문 제한은 1 MB입니다. 더 큰 파일에는 스트리밍하는 CLI를 쓰세요.
응답
200 OK · application/json
{
"output": "SGVsbG8sIGh1YiE=",
"variant": "standard",
"padding": true,
"bytes_in": 11,
"bytes_out": 16
}
| 필드 | 타입 | 설명 |
|---|---|---|
output | string | Base64 텍스트. |
variant | string | 사용한 알파벳, standard 또는 url. |
padding | boolean | = 패딩을 유지했는지. |
bytes_in | integer | UTF-8로 변환한 뒤의 입력 바이트 수. |
bytes_out | integer | 줄 바꿈을 포함한 output의 길이. |
{"input": "foobar", "wrap": 4}이면 출력은 "Zm9v\nYmFy"이고 bytes_out은 9입니다. Base64 문자 8개와 줄 바꿈 하나입니다. 위 응답은 읽기 쉽게 정리한 것이며 API는 한 줄로 보냅니다.
오류
| 상태 | 코드 | 원인 |
|---|---|---|
| 400 | invalid_body | 유효하지 않은 JSON, input이 없거나 문자열이 아님, 잘못된 variant, padding, wrap, 알 수 없는 필드나 쿼리 매개변수, JSON 본문과 함께 보낸 쿼리 옵션. |
| 413 | too_large | 본문이 1 MB를 넘음. |
| 415 | unsupported_media_type | Content-Type이 application/json이나 application/octet-stream이 아님. |
| 429 | 없음 | 요청 한도 도달. 제한 참고. |
모든 오류는 API 개요에 정리되어 있습니다.
업데이트 2026. 11. 22.