New in 2.4: Test runs you can trust See what's new →

Decode a base64 string

GEThttps://api.testingapis.com/api/utils/base64/decode

If the decoded bytes are not valid UTF-8, decoded is null and hex holds the bytes.

Parameters 1

NameTypeDescription
valuequery · stringStandard or URL-safe base64, with or without padding. Send + as %2B in the query string. Default: "".

Responses

200
Success.
400
value is not valid base64.

Example

Request
curl -X GET "https://api.testingapis.com/api/utils/base64/decode?value=aGVsbG8gd29ybGQ%3D"
Run in Studio
Response200 OK
{
  "input": "aGVsbG8gd29ybGQ=",
  "decoded": "hello world",
  "isUtf8": true,
  "hex": "68656c6c6f20776f726c64",
  "length": 11
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/utils/base64/decode?value=aGVsbG8gd29ybGQ%3D");
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "GET",
    "https://api.testingapis.com/api/utils/base64/decode?value=aGVsbG8gd29ybGQ%3D",
    allow_redirects=False,
)
print(response.status_code, response.text)
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.testingapis.com/api/utils/base64/decode?value=aGVsbG8gd29ybGQ%3D"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}