On this page
Overview
Gson is a Java library for converting objects to JSON and JSON back to Java objects. It supports existing classes and generic types and can customize representation with TypeAdapters. Version 2.14.0 adds built-in java.time adapters and reduces reflective access to JDK internals.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Convert Java objects with toJson and fromJson
Gson can serialize and deserialize existing classes without requiring source changes or annotations on every model.
Sources: [1]
Handle generic and custom representations with TypeToken and TypeAdapter
TypeToken carries generic type information while custom adapters provide explicit mappings for special formats and third-party classes.
Use built-in java.time adapters in 2.14.0
Adapters for classes such as Instant and Duration avoid the prior reliance on reflective access to private JDK fields and the corresponding --add-opens workaround.
Sources: [2]
Best fit
Fits lightweight JSON mapping in Java applications
It works well for API payloads, configuration, and straightforward object mapping when schema or code generation is not required.
Sources: [1]
Before adoption
The project is in maintenance mode
The README says existing bugs will be fixed but large new features are unlikely, which matters when choosing it for long-lived new designs.
Sources: [1]
Official sources
- [1]Gson 2.14.0 README(2026-10-04)
- [2]Gson 2.14.0 release(2026-10-04)
- [3]Gson troubleshooting guide(2026-10-04)
- [4]Gson Apache 2.0 license(2026-10-04)
Supplemental curator note
Gson is in maintenance mode. Upstream does not recommend it for Android because reflection interacts poorly with R8/ProGuard, so compare code-generation alternatives for new Android projects.
Try it in 3 steps
- 1
Create a minimal Maven project for Gson 2.14.0
Pin Gson to 2.14.0 in an isolated Maven project. Gson supports Java 8+, while this sample compiles with Java 17.
mkdir -p gson-demo/src/main/java/demo && printf '%s\n' '<project xmlns="http://maven.apache.org/POM/4.0.0">' '<modelVersion>4.0.0</modelVersion>' '<groupId>demo</groupId><artifactId>gson-demo</artifactId><version>1.0.0</version>' '<properties><maven.compiler.release>17</maven.compiler.release></properties>' '<dependencies><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.14.0</version></dependency></dependencies>' '</project>' > gson-demo/pom.xml - 2
Create a small object-to-JSON example
Use a plain Java class with no Gson annotations and serialize it with
toJson.printf '%s\n' 'package demo;' 'import com.google.gson.Gson;' 'public class Main {' ' static class User { String name = "Ada"; int id = 42; }' ' public static void main(String[] args) { System.out.println(new Gson().toJson(new User())); }' '}' > gson-demo/src/main/java/demo/Main.java - 3
Compile and verify the JSON output
Resolve Gson 2.14.0, compile the project, and confirm that the Java object is serialized to JSON.
cd gson-demo && mvn -q compile dependency:build-classpath -Dmdep.outputFile=cp.txt && java -cp "target/classes:$(cat cp.txt)" demo.Main
Growth
Growth trends · Last 30 days
24,233 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 12
- Open PRs
- 109
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
- Stars
- 24,233
- Forks
- 4,489
- Watchers
- 739
- Open issues
- 224
- Contributors
- 175
- Owner type
- Organization
- Primary language
- Java
- License
- Apache-2.0
- Repository last updated
- Oct 1, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Jackson9,818 Stars
2 shared tag(s) · 1 shared category(s)
navigate Jackson's Java and JVM data-processing ecosystem across streaming, databinding, format modules, and supported release lines
- REST Assured7,139 Stars
2 shared tag(s) · Same language
test REST APIs from Java with a DSL for requests, status, headers, and JSON/XML assertions
Java - ZEN Engine2,034 Stars
2 shared tag(s)
define a business decision once in JSON and deliver it across runtimes
Rust - DBeaver51,949 Stars
1 shared tag(s) · 1 shared category(s) · Same language
operate many database systems from one desktop SQL workspace
Java - Netty35,065 Stars
1 shared tag(s) · 1 shared category(s) · Same language
Build high-connection protocol servers and clients in Java from event loops and channel pipelines
Java - OpenAPI Generator26,772 Stars
1 shared tag(s) · 1 shared category(s) · Same language
Generate client SDKs, server stubs, documentation, and configuration for many languages from one OpenAPI contract
Java
Report incorrect information
Tell us if any listing information is incorrect or outdated.