🌐
Maven Repository
mvnrepository.com › artifact › com.google.code.gson › gson
Maven Repository: com.google.code.gson » gson
September 10, 2025 - Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example ...
open-source Java library to serialize and deserialize Java objects to and from JSON
Gson, or Google Gson, is an open-source Java library that serializes Java objects to JSON (and deserializes them back to Java). The Gson library was originally developed for internal purposes at Google, … Wikipedia
Factsheet
Google Gson
Developer Google
Initial release May 22, 2008; 17 years ago (2008-05-22)
Factsheet
Google Gson
Developer Google
Initial release May 22, 2008; 17 years ago (2008-05-22)
🌐
GitHub
github.com › google › gson
GitHub - google/gson: A Java serialization/deserialization library to convert Java Objects into JSON and back · GitHub
Gson jar downloads are available from Maven Central.
Starred by 24.3K users
Forked by 4.4K users
Languages   Java
🌐
Maven Central
repo1.maven.org › maven2 › com › google › code › gson › gson › 2.10.1
Central Repository: com/google/code/gson/gson/2.10.1
../ gson-2.10.1-javadoc.jar 2023-01-06 15:44 706662 gson-2.10.1-javadoc.jar.asc 2023-01-06 15:44 496 gson-2.10.1-javadoc.jar.md5 2023-01-06 15:44 32 gson-2.10.1-javadoc.jar.sha1 2023-01-06 15:44 40 gson-2.10.1-sources.jar 2023-01-06 15:44 181840 gson-2.10.1-sources.jar.asc 2023-01-06 15:44 496 gson-2.10.1-sources.jar.md5 2023-01-06 15:44 32 gson-2.10.1-sources.jar.sha1 2023-01-06 15:44 40 gson-2.10.1.jar 2023-01-06 15:44 283367 gson-2.10.1.jar.asc 2023-01-06 15:44 496 gson-2.10.1.jar.md5 2023-01-06 15:44 32 gson-2.10.1.jar.sha1 2023-01-06 15:44 40 gson-2.10.1.pom 2023-01-06 15:44 9365 gson-2.10.1.pom.asc 2023-01-06 15:44 496 gson-2.10.1.pom.md5 2023-01-06 15:44 32 gson-2.10.1.pom.sha1 2023-01-06 15:44 40
🌐
Maven Central
central.sonatype.com › artifact › com.google.code.gson › gson
Maven Central - com.google.code.gson - Sonatype
--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.google.code.gson</groupId> <artifactId>gson-parent</artifactId> <version>2.13.2</version> </parent> <artifactId>gson</artifactId> <name>Gson</name> <licenses> <license> <name>Apache-2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url> </license> </licenses> <properties> <!-- Make the build reproducible, see root `pom.x
🌐
Maven Repository
mvnrepository.com › artifact › com.google.gson
Maven Repository: com.google.gson
aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi persistence plugin resources rlang sdk server service ...
🌐
Jenkov
jenkov.com › tutorials › java-json › gson-installation.html
GSON - Installation
June 13, 2015 - To use GSON in your Java application you need to include the GSON JAR file in the classpath of your Java application. You can do so either by adding GSON as a Maven dependency to your project, or by downloading the JAR file and include it in the classpath manually.
🌐
Maven Central
central.sonatype.com › artifact › com.google.code.gson › gson › 2.10.1
com.google.code.gson:gson:2.10.1 - Maven Central
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> ... <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.google.code.gson</groupId> <artifactId>gson-parent</artifactId> <version>2.10.1</version> </parent> <artifactId>gson</artifactId> <name>Gson</name> <licenses> <license> <name>Apache-2.0</name> <url>https://www.apac
Find elsewhere
🌐
Maven Repository
mvnrepository.com › artifact › com.google.code.gson › gson › 2.10.1
Maven Repository: com.google.code.gson » gson » 2.10.1
January 6, 2023 - HomePage https://github.com/google/gson 🔍 Inspect URL · Links · DateJan 06, 2023 · Filespom (9 KB)jar (276 KB)View All · RepositoriesCentralAlessioDPAlfrescoAuxilorCarmGaelGluuIceCreamQAQInstreamaticGroovyPluginsKyligence PublicLaninkLoohpJamesMineVoltMulesoftSpaceIOTitanValeUSITWSO2 PublicXceptance+17 more · Ranking · #20in MvnRepository · #3in JSON Libraries · 💡 · Newer Version Available · 2.10.1→2.13.2 · (4 changes) Maven ·
Published   Jan 06, 2023
Version   2.10.1
🌐
Maven Central
central.sonatype.com › artifact › com.google.code.gson › gson › 2.8.5
com.google.code.gson:gson:2.8.5 - Maven Central
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.5</version> </dependency> ... <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.google.code.gson</groupId> <artifactId>gson-parent</artifactId> <version>2.8.5</version> </parent> <artifactId>gson</artifactId> <name>Gson</name> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>jun
🌐
GitHub
github.com › google › gson › blob › main › UserGuide.md
gson/UserGuide.md at main · google/gson
To use Gson with Maven2/3, you can use the Gson version available in Maven Central by adding the following dependency:
Author   google
🌐
Maven Central
repo.maven.apache.org › maven2 › com › google › code › gson › gson-parent › 2.11.0 › gson-parent-2.11.0.pom
https://repo.maven.apache.org/maven2/com/google/code/ ...
spotless-maven-plugin · 2.43.0 · check · *.md · *.xml · .github/**/*.yml · .gitignore · true · 2 · src/test/java/com/google/gson/functional/Java17RecordTest.java · src/test/java/com/google/gson/native_test/Java17RecordReflectionTest.java · true · true ·
🌐
Maven Repository
mvnrepository.com › artifact › com.google.code.gson › gson › 2.11.0
Maven Repository: com.google.code.gson » gson » 2.11.0
May 19, 2024 - HomePage https://github.com/google/gson 🔍 Inspect URL · Links · DateMay 19, 2024 · Filespom (11 KB)jar (291 KB)View All · RepositoriesCentralAlessioDPAlfrescoAuxilorCarmGaelInstreamaticLaninkLoohpJamesSpaceIOTitanValeUSITWSO2 PublicXceptance+11 more · Ranking · #20in MvnRepository · #3in JSON Libraries · 💡 · Newer Version Available · 2.11.0→2.13.2 · (4 changes) Maven ·
Published   May 19, 2024
Version   2.11.0
🌐
GitHub
google.github.io › gson › UserGuide.html
Gson User Guide | gson
To use Gson with Maven2/3, you can use the Gson version available in Maven Central by adding the following dependency:
🌐
Maven Repository
mvnrepository.com › artifact › com.google.code.gson › gson › 2.8.5
Maven Repository: com.google.code.gson » gson » 2.8.5
May 22, 2018 - Gson is a Java library that can be used to convert Java Objects into their JSON representation. Links · JSON Libraries · JSON Schema Libraries · JSON-LD Libraries · JSON Query Libraries · JSON-RPC Libraries · Maven Plugins · Testing · Android Packages ·
Published   May 22, 2018
Version   2.8.5
Top answer
1 of 4
20

Try:

<dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
</dependency>

I have edited my comment and added the scope. The default scope is compile, meaning that the dependency is not present at runtime. For this, you use the provided scope. More about scopes in maven dependencies on Apache's Introduction to Maven Dependencies.

Hope this resolves your issue.

P.S.: if you are creating your own repository, you should also take a look here.

2 of 4
4

Just a clarification on Raul's answer - good that it works for you, but provided is for dependencies that are expected to be available from the JRE/JDK, ie servlet classes. Compile is the default and should work in other people's cases, as gson isn't available from a JRE, instead it needs to be downloaded by maven. From http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope:

compile This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

runtime This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.

test This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.

system This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.

import (only available in Maven 2.0.9 or later) This scope is only used on a dependency of type pom in the section. It indicates that the specified POM should be replaced with the dependencies in that POM's section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

🌐
Maven Central
central.sonatype.com › artifact › com.google.code.gson › gson › 2.9.0
com.google.code.gson:gson:2.9.0 - Maven Central
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.9.0</version> </dependency> Copy to clipboard · <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.google.code.gson</groupId> <artifactId>gson-parent</artifactId> <version>2.9.0</version> </parent> <artifactId>gson</artifactId> <name>Gson</name> <licenses> <license> <name>Apache-2.0</name> <url>h
🌐
Maven Repository
mvnrepository.com › artifact › com.google.code.gson
Maven Repository: com.google.code.gson
Google Gson grab bag of utilities, type adapters, etc. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi persistence plugin resources rlang sdk server service spring sql starter testing tools ui web webapp