Kotlin @Serializable annotation not working in IntelliJ

You need to add :

plugins {
    application
    kotlin("jvm") version "1.4.21"
    kotlin("plugin.serialization") version "1.4.21"
}

This is specified by JetBrains here, linked to gradle:

https://github.com/Kotlin/kotlinx.serialization#setup

https://ktor.io/docs/kotlin-serialization.html#add_dependencies


So I got this working. The problem was that I was using the idea plugin to generate the IntelliJ project. When I instead imported the project by opening the build.gradle.kts file, everything works as expected.

The reason I didn't import it that way in the first place is because I had disabled Gradle support, so when I opened the build.gradle.kts file, it didn't import the project, it just opened it in an editor. If you have this situation, hit cmd+shift+a and search for Gradle and then toggle that switch to On. After a reboot of IntelliJ you should be able to import the project from the build.gradle.kts file and you should be good to go.