POST디코딩
Base64를 텍스트나 원래 바이트로 되돌립니다. 입력은 어느 알파벳을 써도 되고, 패딩이 없거나 data: 접두사가 붙어 있어도 됩니다.
POST
https://api.base64hub.com/v1/decode요청
Base64를 JSON의 input으로 보내거나, Content-Type: text/plain으로 본문 전체에 담아 보내세요.
curl -s https://api.base64hub.com/v1/decode \
-H 'Content-Type: application/json' \
-d '{"input": "SGVsbG8sIGh1YiE="}'
const res = await fetch("https://api.base64hub.com/v1/decode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: "SGVsbG8sIGh1YiE=" }),
});
const data = await res.json();
console.log(data.output); // Hello, hub!
import json
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/decode",
data=json.dumps({"input": "SGVsbG8sIGh1YiE="}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as res:
print(json.load(res)["output"]) # Hello, hub!
b64 -d SGVsbG8sIGh1YiE=
# Hello, hub!
본문 매개변수
| 이름 | 타입 | 설명 |
|---|---|---|
input 필수 | string | 디코딩할 Base64. |
Content-Type: text/plain이면 JSON 없이 본문 전체가 입력입니다. 이 엔드포인트는 쿼리 매개변수를 받지 않습니다.
디코더가 받아들이는 것:
- 어디에 있든 공백, 탭, 줄 바꿈(예: MIME 형식으로 줄 바꿈한 Base64)
data:<type>;base64,접두사(제거됨)- 빠진
=패딩 - 표준 알파벳과 URL-safe 알파벳(섞여 있어도 됨)
응답
200 OK · application/json
{
"output": "Hello, hub!",
"utf8": true,
"bytes_out": 11
}
디코딩한 바이트가 유효한 UTF-8이 아니면 output은 null이고 바이트는 16진수로 옵니다. +/+/에 대한 응답은 다음과 같습니다.
200 OK · application/json
{
"output": null,
"utf8": false,
"hex": "fbffbf",
"bytes_out": 3
}
| 필드 | 타입 | 설명 |
|---|---|---|
output | string 또는 null | 디코딩한 텍스트. 바이트가 UTF-8이 아니면 null. |
utf8 | boolean | 바이트가 유효한 UTF-8인지. |
hex | string | 소문자 16진수로 나타낸 바이트. utf8이 false일 때만 있음. |
bytes_out | integer | 디코딩한 바이트 수. |
원시 바이트
파일을 돌려받으려면 Accept: application/octet-stream으로 바이트를 요청하세요. 그러면 응답 본문은 JSON 없이 디코딩한 데이터 그대로입니다.
curl -s https://api.base64hub.com/v1/decode \
-H 'Content-Type: text/plain' \
-H 'Accept: application/octet-stream' \
--data-binary @photo.b64 -o photo.jpg
const res = await fetch("https://api.base64hub.com/v1/decode", {
method: "POST",
headers: { "Content-Type": "text/plain", Accept: "application/octet-stream" },
body: "SGk=",
});
const bytes = new Uint8Array(await res.arrayBuffer());
console.log(bytes); // Uint8Array(2) [ 72, 105 ]
import urllib.request
req = urllib.request.Request(
"https://api.base64hub.com/v1/decode",
data=b"SGk=",
headers={"Content-Type": "text/plain", "Accept": "application/octet-stream"},
)
with urllib.request.urlopen(req) as res:
print(res.read()) # b'Hi'
b64 -d -i photo.b64 -o photo.jpg
오류
잘못된 Base64는 400 invalid_base64로 거부됩니다. 메시지는 첫 번째 문제와 그 위치를 알려 주며, 위치는 공백을 제거한 뒤 0부터 셉니다.
400 Bad Request · application/json
{"error":{"code":"invalid_base64","message":"invalid character '!' at position 4"}}
| 상태 | 코드 | 원인 |
|---|---|---|
| 400 | invalid_base64 | 두 알파벳 어디에도 없는 문자, 중간의 =, 세 개 이상의 =, 마지막 묶음에 한 글자만 남는 길이. |
| 400 | invalid_body | 유효하지 않은 JSON, input이 없거나 문자열이 아님, 알 수 없는 필드, 쿼리 매개변수, UTF-8이 아닌 본문. |
| 413 | too_large | 본문이 1 MB를 넘음. |
| 415 | unsupported_media_type | Content-Type이 application/json이나 text/plain이 아님. |
| 429 | 없음 | 요청 한도 도달. 제한 참고. |
오류 상태를 받지 않고 문자열을 검사하려면 검증을 쓰세요.
업데이트 2026. 11. 22.