OSS TanbouSign in with GitHub

convert Kotlin and Java objects to and from JSON with typed adapters

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
10,165
Primary language
Kotlin
License
Apache-2.0
Repository last updated
Oct 1, 2026
On this page

Overview

Moshi is a JSON library for Android, Java, and Kotlin. JsonAdapter connects JSON reading and writing to application types, with built-in adapters, custom adapters, and either reflection or code generation for Kotlin models.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Centralize JSON-to-type conversion in JsonAdapter

Moshi handles primitives, collections, strings, enums, and model types through JsonAdapter instances. The same adapter owns fromJson and toJson behavior for a model.

Sources: [2]

Extend mappings with custom adapters and Kotlin code generation

Custom @FromJson and @ToJson methods can define application-specific mappings. Kotlin models can use KotlinJsonAdapterFactory reflection or moshi-kotlin-codegen through KSP.

Sources: [2][3]

Best fit

Fits Android and JVM clients that map API JSON into explicit models

Applications can keep JSON response handling at typed boundaries and control nulls, unexpected values, and custom formats through adapters rather than spreading parsing logic through business code.

Sources: [2]

Before adoption

Choose the Kotlin adapter strategy deliberately and separate stable 1.x from the 2.x preview

Plain Java reflection is unsupported for Kotlin classes, so Kotlin models need code generation or KotlinJsonAdapterFactory. Stable 1.15.2 also coexists with a 2.0.0-alpha.1 preview whose Kotlin-facing changes can affect source compatibility; review the migration notes before adopting the preview.

Sources: [2][4]

Official sources

  1. [1]square/moshi — GitHub repository(2026-10-06)
  2. [2]Moshi 1.15.2 — README(2026-10-06)
  3. [3]Moshi 1.15.2 — CHANGELOG(2026-10-06)
  4. [4]Moshi current CHANGELOG(2026-10-06)
  5. [5]Moshi Apache-2.0 license(2026-10-06)
Supplemental curator note

Moshi works well for explicit JSON model boundaries on Android and the JVM. Choose between reflection and KSP code generation for Kotlin models, and evaluate the 2.x preview separately from the stable 1.x line.

Try it in 3 steps

  1. 1

    Add the Moshi 1.15.2 Kotlin adapter

    Pin stable 1.15.2 and use KotlinJsonAdapterFactory reflection for this minimal check.

    implementation("com.squareup.moshi:moshi-kotlin:1.15.2")
  2. 2

    Create Moshi and a typed adapter

    Register the Kotlin adapter factory and obtain a JsonAdapter for the User type.

    import com.squareup.moshi.Moshi import com.squareup.moshi.adapter import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory data class User(val name: String) val moshi = Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build() val adapter = moshi.adapter<User>()
  3. 3

    Decode JSON into the Kotlin object

    Call fromJson with a minimal JSON document and confirm that it produces a User object.

    println(adapter.fromJson("""{"name":"Moshi"}"""))
Check the official README

Growth

Growth trends · Last 30 days

10,165 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
0
Open PRs
19

Development activity is still being collected.

Built with

Categories and tags

Categories

GitHub data

GitHub dataView detailed GitHub data
Stars
10,165
Forks
811
Watchers
182
Open issues
94
Contributors
83
Owner type
Organization
Primary language
Kotlin
License
Apache-2.0
Repository last updated
Oct 1, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?