Most of these other answers are explaining the general concept of serialization, but the OP seems to be asking a more specific question: they understand what serialization is, but they've noticed that many codebases serialize Java objects (e.g. to JSON) without implementing the Serializable interface. If this is the case, what's the purpose of the interface? Let me start off by saying that in my experience, the Serializable does not seem to be used very often in modern codebases. Nowadays, most modern codebases tend to prefer to do serialization via a library like Gson, Jackson, SnakeYAML, protobuf, etc. Now to directly answer your question, I think you haven't completely internalized the purpose of an interface yet. Let me do an analogy with electrical outlets. The electrical grid in America vs Europe are built to different standards. In the USA, an electrical outlet will provide 120 volts at 60 Hz, while in many places in Europe, it will provide 240 Volts at 50 Hz. If you want to build an appliance, say a television, you can build one that works to the US standard, or you can build one that works to the European standard. Either one works fine, but you as a TV designer, need to know ahead of time whether you're expecting to receive a US-style power source or a European-style power source so that you can put the right type of circuitry to make sure your television works. Interfaces (in all programming languages, not just Java) act like standards and specifications that allow two software modules to work together, just like the US electrical standard is designed so that any US appliance can work in any US electrical outlet. They provide a guarantee about what sort of functionality an implementing object will provide (e.g. 120 volts at 60Hz) that the caller can rely on to build whatever additional functionality they want on top of it. If you want to integrate with the java.io.ObjectInputStream and java.io.ObjectOutputStream pair of classes (which help perform serialization for you), you need to implement the Serializable interface, just like if you want your television to work with US outlets, you need to design it to work with 120 volts and 60 hz. If you don't care about using ObjectInputStream and ObjectOutputStream, you don't have to implement that interface (maybe your television uses batteries or has a solar panel, in which case you don't need to worry about designing a plug that fits a US outlet). In languages with static type checking, such as Java, the compiler will prevent you from using a class in an API that requires a specific interface is that class does not implement that interface. This is analogous to the idea that the shapes of US electrical outlets are different from European outlets, so you can't accidentally plug in a TV into an outlet that it won't work with. TL;DR: So the answer to your question is that the Serializable is needed when you interact with an API that requires an instance of Serializable -- the vast majority of type, that API will be the java.io.ObjectInputStream and java.io.ObjectOutputStream APIs. If you don't interact with those kinds of APIs, you don't need to implement the Serializable. And in fact, most modern codebases don't rely on ObjectInputStream and ObjectOutputStream to perform serialization, and so most codebases won't bother to have their classes implement Serializable even if though they still intended to serialize those objects -- they simply intend to use a different API to perform that serialization. Answer from Nebu on reddit.com
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › Serializable.html
Serializable (Java Platform SE 8 )
April 21, 2026 - Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable.
🌐
Reddit
reddit.com › r/javahelp › explain like i'm five - what is serializable?
r/javahelp on Reddit: Explain like i'm five - what is Serializable?
April 26, 2024 -

I just don't get it. I'm a junior and see it often in the codebase of the company i work at. Documentation says that it helps serialize and deserialize objects, but why does that need to happen using this interface? There are so many classes that do not implement Serializable, so what happens to them?
Head First Java book says that objects need to be serialized when data is sent over the network or saved to a disk. But there is serialization/deserialization happening to JSON objects for example when they're being sent from server to client and vice versa, and those classes do not implement Serializable.
So in which "special" scenario does one need/want to implement Serializable?

Confused about what serializable means Dec 1, 2018
r/AskComputerScience
7y ago
Why add Serialization 2.0? Nov 6, 2025
r/java
8mo ago
[Java] Newbie - Real life uses of Serialization? Aug 4, 2016
r/learnprogramming
9y ago
Serializing Java 14 Records Mar 5, 2020
r/java
6y ago
More results at reddit.com
Discussions

java - When should we implement Serializable interface? - Stack Overflow
Implement the Serializable interface when you want to be able to convert an instance of a class into a series of bytes or when you think that a Serializable object might reference an instance of your class. Serializable classes are useful when you want to persist instances of them or send them over a wire. Instances of Serializable classes can be easily transmitted. Serialization does have some security consequences, however. Read Joshua Bloch's Effective Java... More on stackoverflow.com
🌐 stackoverflow.com
ELI5: Serialization in programming

Serialization is a process of converting an object graph (essentially, a bunch of interrelated "things") into a format that can be stored in memory, on disk, or transmitted over a network.

The opposite of this is called deserialization, which is where you take that data and turn it back into the objects your program needs to work with. This is useful for things like saving the state of a program, or transferring objects to another computer on the network so that it can perform some necessary operations on them.

More on reddit.com
🌐 r/explainlikeimfive
2
1
May 27, 2014
Explain like i'm five - what is Serializable?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
9
24
April 26, 2024
Sealed interface serialization
You can change the name/content of that field, but removing it defeats the purpose of polymorphic serialization entirely. More on reddit.com
🌐 r/Kotlin
23
7
September 16, 2023
People also ask

What happens if a class does not implement the Serializable interface in Java, but serialization is attempted?
If a class does not implement the Serializable interface and you try to serialize its objects, Java will throw a NotSerializableException. This is because the serialization mechanism relies on this marker interface to confirm that the class is explicitly allowing its instances to be serialized. Without this, Java prevents serialization to avoid unintended behavior or data corruption.
🌐
upgrad.com
upgrad.com › home › blog › software development › understanding the serializable in java: serializable interface with examples
Serializable in Java: Complete Guide with Examples
Can you serialize objects that contain references to non-serializable classes?
No, Java serialization requires that all objects referenced directly or indirectly by the object being serialized must themselves implement Serializable. If the serializer encounters a non-serializable object, it throws a NotSerializableException. To handle this, you can mark such fields as transient to exclude them or provide custom serialization methods to manage their state separately.
🌐
upgrad.com
upgrad.com › home › blog › software development › understanding the serializable in java: serializable interface with examples
Serializable in Java: Complete Guide with Examples
Can static fields be serialized in Java?
No, static fields belong to the class itself rather than any individual object instance. Since serialization captures the state of a specific object, static fields are excluded because their value is shared across all instances and maintained separately in the class memory area. If you want to persist static data, you need to handle it separately outside the serialization mechanism.
🌐
upgrad.com
upgrad.com › home › blog › software development › understanding the serializable in java: serializable interface with examples
Serializable in Java: Complete Guide with Examples
🌐
GeeksforGeeks
geeksforgeeks.org › java › serializable-interface-in-java
Serializable Interface in Java - GeeksforGeeks
June 10, 2026 - The Serializable interface in Java is a marker interface available in the java.io package. It is used to indicate that the objects of a class can be converted into a byte stream (serialization) and later reconstructed back into objects ...
🌐
Medium
medium.com › javarevisited › a-deep-dive-into-the-serializable-interface-and-serialization-process-3b6bd048e2d6
A Deep Dive into the Serializable Interface and Serialization Process | by TinyTechThreads𓍯𓂃 | Javarevisited | Medium
April 28, 2025 - So, while you don’t write any methods in Serializable, the mere presence of this marker unlocks a powerful system already waiting in the background. When your class implements Serializable, it's silently entering into an agreement with Java's serialization engine. This agreement is enforced by the Java I/O libraries and acts like a contract that both sides must respect. Think of it this way: The marker interface doesn’t do the work — it just shows that you’ve signed the contract.
Top answer
1 of 3
193
  1. From What's this "serialization" thing all about?:

    It lets you take an object or group of objects, put them on a disk or send them through a wire or wireless transport mechanism, then later, perhaps on another computer, reverse the process: resurrect the original object(s). The basic mechanisms are to flatten object(s) into a one-dimensional stream of bits, and to turn that stream of bits back into the original object(s).

    Like the Transporter on Star Trek, it's all about taking something complicated and turning it into a flat sequence of 1s and 0s, then taking that sequence of 1s and 0s (possibly at another place, possibly at another time) and reconstructing the original complicated "something."

    So, implement the Serializable interface when you need to store a copy of the object, send them to another process which runs on the same system or over the network.

  2. Because you want to store or send an object.

  3. It makes storing and sending objects easy. It has nothing to do with security.

2 of 3
130

The answer to this question is, perhaps surprisingly, never, or more realistically, only when you are forced to for interoperability with legacy code. This is the recommendation in Effective Java, 3rd Edition by Joshua Bloch:

There is no reason to use Java serialization in any new system you write

Oracle's chief architect, Mark Reinhold, is on record as saying removing the current Java serialization mechanism is a long-term goal.


Why Java serialization is flawed

Java provides as part of the language a serialization scheme you can opt in to, by using the Serializable interface. This scheme however has several intractable flaws and should be treated as a failed experiment by the Java language designers.

  • It fundamentally pretends that one can talk about the serialized form of an object. But there are infinitely many serialization schemes, resulting in infinitely many serialized forms. By imposing one scheme, without any way of changing the scheme, applications can not use a scheme most appropriate for them.
  • It is implemented as an additional means of constructing objects, which bypasses any precondition checks your constructors or factory methods perform. Unless tricky, error prone, and difficult to test extra deserialization code is written, your code probably has a gaping security weakness.
  • Testing interoperability of different versions of the serialized form is very difficult.
  • Handling of immutable objects is troublesome.

What to do instead

Instead, use a serialization scheme that you can explicitly control. Such as Protocol Buffers, JSON, XML, or your own custom scheme.

Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › io › Serializable.html
Serializable (Java SE 21 & JDK 21)
January 20, 2026 - The serialization interface has no methods or fields and serves only to identify the semantics of being serializable. It is possible for subtypes of non-serializable classes to be serialized and deserialized. During serialization, no data will be written for the fields of non-serializable ...
🌐
Medium
medium.com › hello-java › mastering-java-serializable-interface-with-examples-b0b53a39345a
Mastering Java Serializable Interface with Examples | by Larry | Peng Yang | Mastering Java | Medium
June 18, 2023 - The Serializable interface in Java is used whenever you need to serialize an object, which means converting its state to a byte stream, so that it can be saved to a database, sent over a network, or stored in a file, etc.
🌐
Upgrad
upgrad.com › home › blog › software development › understanding the serializable in java: serializable interface with examples
Serializable in Java: Complete Guide with Examples
1 week ago - To make an object serializable in Java, its class must implement the Serializable interface from the java.io package. This marker interface has no methods but signals to the JVM that objects of the class can be converted to a byte stream for ...
🌐
Medium
medium.com › @hxu0407 › serializable-in-java-why-it-matters-for-your-spring-boot-microservices-567043ce81f2
Serializable in Java Why It Matters for Your Spring Boot Microservices | by Hui | Medium
March 25, 2025 - At the start, you melt it into liquid metal — this is like serialization. When it reaches the destination, you cast it back into its original shape — this is deserialization. In programming terms, we know that the smallest unit of communication between computers is a stream of bytes.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › stringify
JSON.stringify() - JavaScript | MDN
Boolean, Number, String, and BigInt (obtainable via Object()) objects are converted to the corresponding primitive values during stringification, in accordance with the traditional conversion semantics. Symbol objects (obtainable via Object()) are treated as plain objects. Attempting to serialize BigInt values will throw.
🌐
Playwright
playwright.dev › page
Page | Playwright
Playwright also supports transferring some additional values that are not serializable by JSON: -0, NaN, Infinity, -Infinity.
🌐
Zhihu
zhihu.com › en › answer › 2305388910
Why does Java require implementing the Serializable ...
Can you accept that your future child will take the mother's surname · Actually, I still support it. If it's a two-way marriage, the economic burden on families with sons would be reduced by more than a little.Actually, I still support it. If it's a two-way marriage, the economic burden on ...
🌐
Baeldung
baeldung.com › home › persistence › jpa › jpa entities and the serializable interface
JPA Entities and the Serializable Interface | Baeldung
January 8, 2024 - If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface. In practice, if our object is to leave the domain of the JVM, it’ll require serialization. Each entity class consists of persistent fields and properties. The specification requires that fields of an entity may be Java primitives, Java serializable types, or user-defined serializable types.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › marker interface in java: serializable and cloneable
Marker Interface In Java: Serializable And Cloneable
April 1, 2025 - In Java, we have three interfaces that are Marker interfaces as shown below: #1) Serializable interface: Serializable is a marker interface present in the java.io package. We can serialize objects using this interface i.e.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › index.html
Uses of Interface java.io.Serializable (Java Platform SE 8 )
April 21, 2026 - JavaScript is disabled on your browser · Frame Alert · This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version
🌐
Medium
frankie95.medium.com › java-serializable-interface-for-beginner-1b831924c3f4
Java Serializable interface for beginner | by Frankie | Medium
May 11, 2020 - Java Serializable interface for beginner Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have …
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
April 21, 2026 - A Comparator that orders String objects as by compareToIgnoreCase. This comparator is serializable. Note that this Comparator does not take locale into account, and will result in an unsatisfactory ordering for certain locales. The java.text package provides Collators to allow locale-sensitive ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › template
<template> HTML content template element - HTML | MDN
May 23, 2026 - The value should be the ID of an element inside the shadow DOM. If set, target references to the host element from outside the shadow DOM will cause the referenced target element to become the effective target of the reference to the host element. ... Sets the value of the serializable property of a ShadowRoot created using this element to true.
🌐
DeepSet
haystack.deepset.ai
Haystack | Haystack
Run production workloads across any environment with built-in reliability and observability. Haystack Pipelines are serializable, cloud-agnostic, and Kubernetes-ready, with logging, monitoring, and deployment guides to support you.