Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate a TypeScript client from Spring REST endpoints, use a build-time generator that reads Spring MVC controller annotations and Java model metadata, then emits TypeScript models and HTTP client code. The right choice depends on your Spring stack, frontend client style, serialization rules, and build system. The main options include typescript-generator, spring2ts, spring-rest2ts-generator, and Apina.

How a Spring REST TypeScript generator works

A generator examines controller annotations and Java classes during the build and produces TypeScript files for frontend use. Depending on the tool and configuration, those files can describe JSON models, implement HTTP requests, or provide framework-specific services.

This is build-time code generation, not a runtime schema registry. If an endpoint annotation, Java model, or serialization rule changes, regenerate the output and review it as part of the API change. Otherwise, the frontend can keep using generated code that no longer matches the server.

Compare the main Spring-to-TypeScript generator options

Tool Documented scope Client and model output Build or version details
typescript-generator Generates TypeScript declarations from Java classes and can generate REST clients in Spring mode. Supports global, module, and ambientModule output kinds, and declaration or implementation files. Spring client generation requires generateSpringApplicationClient=true and the typescript-generator-spring module. Add the Maven plugin and keep the support module at the same version; the documentation snapshot does not state a version number here.
spring2ts Generates a REST client directly from Spring MVC application source. Documents generated model interfaces, one service class per shared service, and a request-builder helper. Documents a Maven plugin and a Java SourceGen API with source and output directories. The documentation cited here does not state a version number.
spring-rest2ts-generator Generates TypeScript interfaces, models, and working services from Spring MVC annotations. Its feature list also includes JAX-RS and Spring WebFlux support, with WebFlux support documented since version 1.5.0. Documents Angular and React services, Spring Data Pageable/Page handling, Jackson/Gson serializers, and jackson-js conversion. The repository documentation accessed in 2026 lists Maven dependency version 1.5.1 for its modules. Select only the modules your project needs.
Apina Generates client-side TypeScript from Spring MVC controllers and Jackson or Kotlin serialization classes. Client output details are not stated in the cited project information. Build integration and version details are not stated in the cited project information.

Choose based on your backend and frontend

Choose typescript-generator for configurable output types

Use this route when you want Java-derived TypeScript declarations or implementation files and need to choose among global, module, and ambient-module output. Its Spring client mode requires both the configuration flag and the Spring support module; adding only the general generator is not sufficient for that mode.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose spring2ts for explicitly shared MVC classes

spring2ts uses @SharedService and @SharedModel annotations to identify classes intended for the client. Its documented output separates models, service classes, and a request builder. This approach makes the intended shared surface explicit rather than implying that every controller or model should be exposed.

Choose spring-rest2ts-generator when its integrations match your stack

Its documented features cover several client and serialization needs, including Angular and React services, Spring Data pagination, and Jackson or Gson support. The feature list also includes WebFlux and JAX-RS; verify that the specific modules and versions you select fit your application rather than assuming every integration is required.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
  • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

Consider Apina as another controller-based option

Apina is an alternative for generating TypeScript from Spring MVC controllers and Jackson- or Kotlin-serialization classes. The documented facts available here do not establish its client style, build integration, or release recency, so compare those details in the project documentation before adopting it.

Set up generation in the Java build

Configure typescript-generator

  1. Add the typescript-generator Maven plugin to the Java build.
  2. Set generateSpringApplicationClient to true and include the typescript-generator-spring dependency at the same version as the generator.
  3. Choose outputKind (global, module, or ambientModule) and outputFileType (declarationFile or implementationFile) to suit the frontend repository.
  4. Set outputFile to the intended generated-file location, then run generation as part of the build and review changes alongside API changes.

Exact plugin coordinates, configuration syntax, and output-directory conventions depend on the project and are not specified in the documented facts above; use the generator’s own documentation for the applicable configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure spring2ts

  1. Mark the intended shared Java models with @SharedModel and services with @SharedService.
  2. Use the documented Maven plugin or invoke the Java SourceGen API.
  3. Provide the Java source and generated-output directories, then make the frontend consume the generated models and service code.

Choose modules for spring-rest2ts-generator

Select the modules corresponding to the integrations your project uses, such as Spring, Spring Data, Jackson or Gson, WebFlux, JAX-RS, or jackson-js. Its documentation lists dependencies separately; avoid adding unrelated modules just because they are available.

Check model fidelity before relying on generated code

Controller discovery is only part of client correctness. Compare the generated TypeScript with the actual JSON and request behavior, especially where Java types or serializer rules do not map one-to-one.

  • Generics and inheritance: confirm generated types preserve the Java model relationships your frontend uses.
  • Enums: check that generated values match the serialized values returned by the API.
  • Jackson or Gson annotations: verify property names and serialization behavior against the server’s actual JSON.
  • Dates and collections: inspect date, map, and set conversions rather than assuming their TypeScript representations match the Java types.
  • Pagination: if the application uses Spring Data, check that Pageable requests and Page responses are represented as the application expects.

Generated declarations do not by themselves prove that HTTP behavior or serialized payloads are correct. Treat output as code to validate, especially after changing annotations, serializers, or Spring and TypeScript versions.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Spring REST Docs to verify the API surface

Spring REST Docs complements a generator; it does not generate the TypeScript client. It combines hand-written documentation with snippets produced through Spring MVC Test or WebTestClient, which can help verify the endpoints and behavior a generated client is expected to consume. Spring’s project page lists stable version 4.0.0 in its 2026 crawl; check the project documentation for version compatibility with your application.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What to evaluate before adopting a generator

  • Framework coverage: establish whether you need Spring MVC alone, or also WebFlux or JAX-RS.
  • Client style: decide whether the frontend needs declarations only, implementation files, Angular or React services, or another client pattern.
  • Serialization fidelity: test Java generics, inheritance, enums, dates, collections, and serializer annotations against real API payloads.
  • Build integration: confirm Maven or Gradle support and where generated files belong in your repository. The facts listed above document Maven routes for the named tools but do not establish Gradle support.
  • Maintenance and compatibility: check release recency, issue activity, and compatibility with your current Spring and TypeScript versions. The projects’ feature lists do not constitute a maintenance guarantee or a standardized cross-project benchmark.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.