The Best Java API for Global License Plate OCR (Free Image Testing)

Deploy automated license plate recognition (ALPR) built for global scale. Upload a vehicle image for a free test today and extract native scripts and multi-plate layouts seamlessly using Java.

Global License Plate OCR extraction process diagram
StructOCR transforms raw vehicle images into validated JSON with native script retention.

The Problem with Global ALPR Parsers in Java

Enterprise Java applications often struggle with legacy ALPR libraries that are optimized only for standard Latin alphabets. These traditional tools fail when encountering complex layouts from the Middle East or Asia, and struggle to accurately extract native scripts (Arabic, Cyrillic, Thai, Chinese). Furthermore, generic models often lack the ability to process multi-plate setups, like tractor-trailer configurations, or identify secondary data such as plate colors and vehicle types.

The StructOCR Solution

StructOCR allows your Java backend to offload complex vehicle image processing to our specialized deep learning models. Our API transcends generic models by accurately extracting native scripts worldwide exactly as printed. By returning validated JSON directly to your Java application, you can easily integrate multi-dimensional attributes—including plate numbers, vehicle types, and country inferences—into your global logistics and tolling workflows. Explore our flexible pricing to scale your production environment seamlessly.

Common Use Cases

  • Toll Collection & Parking: Automate entry and exit gates globally by capturing primary plate numbers and vehicle classifications instantly.
  • Global Logistics & Border Control: Track multi-plate configurations (e.g., stacked trailer and prime mover plates) simultaneously across international borders.
  • Law Enforcement: Cross-reference vehicle types and plate colors to detect unregistered or commercial vehicles dynamically.

Live Demo: License Plate OCR Scanner

No registration required. Upload a file to test the extraction.

1
Upload
2
Results

Drop files here or click to browse

JPG · PNG · WebP  ·  up to 500 files · max 4.5 MB each

No files selected
Need more testing? Create a free account to get 200 free credits (equals 200 License Plate scans).

Implementation: Raw API Request

Complete, runnable Java 11+ code to encode a vehicle image in Base64 and extract license plate data. For other language examples and deep parameter explanations, visit the full License Plate OCR API Reference.

Prerequisite: JDK 11+ and Gson library

CODE EXAMPLE
// 💰 Save 30%+ vs competitors. Get 200 free credits instantly:
// 👉 https://structocr.com/register

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

public class LicensePlateOcr {

    public static void main(String[] args) throws IOException, InterruptedException {
        String apiKey = "YOUR_API_KEY"; // Replace with your actual API key
        String imagePath = "path/to/your/vehicle_image.jpg"; // Replace with the path to your image

        // 1. Read image and encode to Base64
        byte[] fileContent = Files.readAllBytes(Path.of(imagePath));
        String base64Img = Base64.getEncoder().encodeToString(fileContent);

        // 2. Create JSON payload
        JsonObject payload = new JsonObject();
        payload.addProperty("img", base64Img);
        String jsonPayload = new Gson().toJson(payload);

        // 3. Build the HTTP request (Requires application/json)
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://api.structocr.com/v1/license-plate"))
                .header("x-api-key", apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build();

        System.out.println("Uploading Base64 image to StructOCR API...");

        // 4. Send the request and receive the response
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        // 5. Parse the JSON response
        Gson gson = new Gson();
        JsonObject jsonResponse = gson.fromJson(response.body(), JsonObject.class);

        // 6. Extract the License Plate data
        if (jsonResponse.has("success") && jsonResponse.get("success").getAsBoolean()) {
            JsonObject data = jsonResponse.getAsJsonObject("data");
            System.out.println("✅ Extraction Successful!");
            System.out.println("Plates Detected: " + data.getAsJsonArray("plates").size());
            System.out.println("Country Guess: " + (data.get("country_guess").isJsonNull() ? "N/A" : data.get("country_guess").getAsString()));
            System.out.println("Confidence: " + data.get("confidence").getAsString());
            System.out.println("\n--- Raw Data ---");
            System.out.println(new Gson().toJson(data));
        } else {
            String errorCode = jsonResponse.has("code") ? jsonResponse.get("code").getAsString() : "Unknown Code";
            String errorMsg = jsonResponse.has("message") ? jsonResponse.get("message").getAsString() : "Unknown Error";
            System.out.println("❌ Error [" + errorCode + "]: " + errorMsg);
        }
    }
}

Technical Specs

  • Input format: application/json payload with Base64 encoded string
  • File Constraints: Max 4.5MB (decoded), compress to < 300KB for best speed
  • Supported Formats: Standard Data URI schemas, raw Base64 strings (JPG, PNG, WebP)
  • Language Support: Global scripts (Arabic, Chinese, Thai, Cyrillic, etc.)
  • Output: JSON (Multi-dimensional attributes)

Key Features

  • Global Coverage: Optimized for worldwide plates spanning the Middle East, Asia, Europe, and the Americas.
  • Native Script Retention: Extracts local scripts exactly as printed without translation or transliteration.
  • Multi-Plate Parsing: Natively handles extracting multiple plates from a single vehicle (e.g., stacked trailer plates).

Sample JSON Response

The API returns a clean JSON array with details on all detected plates, preserving native characters and strict enums.

{
  "success": true,
  "data": {
    "plates": [
      {
        "plate_number": "TRE 1631M",
        "plate_color": "yellow",
        "plate_type": "trailer"
      },
      {
        "plate_number": "XB 98X",
        "plate_color": "yellow",
        "plate_type": "commercial"
      }
    ],
    "region_text": null,
    "country_guess": "Singapore",
    "confidence": "High"
  }
}

Frequently Asked Questions

How should I encode the image?

Send the image as a Base64 encoded string wrapped in a JSON payload. The Base64 string must not contain any internal whitespaces or newlines.

What is the maximum file size?

The maximum decoded payload restriction is 4.5MB. Exceeding this will trigger a 413 FILE_TOO_LARGE error.

Can it read non-English characters?

Yes. Our engine natively retains and extracts local scripts like Arabic, Thai, and Cyrillic exactly as printed.

You May Also Like

Related tutorials, platform guides, and comparisons

Tutorial

Python License Plate OCR API

Python License Plate OCR SDK tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Python · License Plate
Tutorial

Go License Plate OCR API

Golang License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Go · License Plate
Tutorial

PHP License Plate OCR API

PHP License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

PHP · License Plate
Tutorial

C# License Plate OCR API

C# License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

C# · License Plate
Tutorial

Node.js License Plate OCR API

Node.js License Plate OCR SDK tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Node.js · License Plate
Tutorial

Java HIN OCR API

Upload an image for a free test! Tutorial: Learn how to integrate the StructOCR API into your Java enterprise applications to extract structured data from Hull Identification Numbers (HIN).

Java · HIN
Country Tutorial

Indonesia Passport OCR with Node.js SDK

Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Indonesia passports.

Node.js · Passport
Country Tutorial

Indonesia KTP (e-KTP) OCR Python SDK

Python Tutorial: Automate KYC in Indonesia. Extract data from KTP (e-KTP) using StructOCR Python SDK. Supports native text.

Python · ktp (e-ktp)
Country Tutorial

India Aadhaar & PAN Card OCR Python SDK

Python Tutorial: Automate KYC in India. Extract data from Indian Aadhaar and PAN Cards using StructOCR Python SDK. Supports Hindi/English parsing and secure format validation.

Python · aadhaar & pan
Country Tutorial

Indonesia Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Indonesia passports with a server-side integration.

Python · Passport

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

From tutorial to production in 5 minutes.

You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.

Instant Access Cancel Anytime 99.9% Uptime