Base64 URL-Safe 인코더 및 디코더
표준 Base64를 URL-Safe Base64로 변환하고 다시 변환합니다. +, /를 -, _로 교체하고 = 패딩을 제거합니다.
100% 클라이언트 사이드 — 데이터가 기기를 떠나지 않습니다
URL-safe Base64 replaces + with - and / with _, and removes trailing = padding. This is used in JWT tokens, URL parameters, and cookies.
코드 예제
프로젝트에 바로 사용할 수 있는 코드 스니펫입니다.
Python
import base64
# Encode to URL-safe Base64 (replaces + with -, / with _)
text = "user@example.com?token=abc123"
safe = base64.urlsafe_b64encode(text.encode()).decode().rstrip("=")
print(safe) # dXNlckBleGFtcGxlLmNvbT90b2tlbj1hYmMxMjM
# Decode URL-safe Base64 (auto-handles missing padding)
decoded = base64.urlsafe_b64decode(safe + "===").decode("utf-8")
print(decoded) # user@example.com?token=abc123
# Convert standard Base64 to URL-safe
std = "abc+def/ghi=="
url_safe = std.replace("+", "-").replace("/", "_").rstrip("=")
print(url_safe) # abc-def_ghi자주 묻는 질문
아래에서 검색하거나 가장 일반적인 질문을 둘러보세요.
표준 Base64는 URL에서 특별한 의미를 가지는 '+'와 '/' 문자를 사용합니다. URL-Safe Base64는 '+'를 '-'로, '/'를 '_'로 대체하고 뒤에 붙는 '=' 패딩을 제거합니다.
Base64 데이터를 URL, 쿼리 파라미터 또는 쿠키에 포함해야 할 때마다 URL-Safe Base64를 사용하세요. 또한 JWT(JSON Web Token)의 표준이기도 합니다.