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 › tutorial › jndi › objects › serial.html
Serializable Objects (The Java™ Tutorials > Java Naming and Directory Interface > Java Objects in the Directory)
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. To serialize an object means to convert its state to a byte stream so that the byte stream can be reverted back into a copy of the object.
🌐
GeeksforGeeks
geeksforgeeks.org › java › serializable-interface-in-java
Serializable Interface in Java - GeeksforGeeks
July 23, 2025 - The Serializable interface is present in java.io package. It is a marker interface. A Marker Interface does not have any methods and fields. Thus classes implementing it do not have to implement any methods.
Discussions

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
java - When should we implement Serializable interface? - Stack Overflow
Oracle's chief architect, Mark Reinhold, is on record as saying removing the current Java serialization mechanism is a long-term goal. Java provides as part of the language a serialization scheme you can opt in to, by using the Serializable interface. More on stackoverflow.com
🌐 stackoverflow.com
serialization - What is Serializable in Java? - Stack Overflow
This is a marker interface to declare this class as serializable. You should google for "java serialization" as this topic is sufficiently covered by hundreds of tutorials and articles. You could even start right at Wikipedia. More on stackoverflow.com
🌐 stackoverflow.com
Serializable What does it acutally do ?
Serializable is mainly a signature interface which indicates that the class that implements it should be able to be serialized, and is used by some of the IO package. It is a bit confusing, but if you read the documentation on the ObjectOutputStream the writeObject method takes a standard Object, not a Serializable, but will then throw a NotSerializableException if the Object (or a parent object in the hierarchy) doesn't implement Serializable. Other serialization mechanisms, like java.beans.XMLEncoder or 3rd party packages like XStream don't seem to care about the Serializable interface. I'm not certain, but I think that RMI required the objects to implement Serializable, possibly because it used object streams. More on reddit.com
🌐 r/java
8
7
July 18, 2014
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
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › Serializable.html
Serializable (Java Platform SE 8 )
March 16, 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.
🌐
Upgrad
upgrad.com › home › blog › software development › understanding the serializable in java: serializable interface with examples
Serializable in Java: Complete Guide with Examples
August 8, 2025 - The Serializable interface in Java is a marker interface used to enable serialization. It is a flag interface that contains no methods but indicates to the Java Virtual Machine (JVM) that the class is capable of being serialized.
🌐
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?

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
🌐
Baeldung
baeldung.com › home › java › core java › introduction to java serialization
Introduction to Java Serialization | Baeldung
May 11, 2024 - Stated differently, serialization is the conversion of a Java object into a static stream (sequence) of bytes, which we can then save to a database or transfer over a network. The serialization process is instance-independent; for example, we can serialize objects on one platform and deserialize them on another. Classes that are eligible for serialization need to implement a special marker interface, Serializable.
🌐
DigitalOcean
digitalocean.com › community › tutorials › serialization-in-java
Serialization in Java - Java Serialization | DigitalOcean
August 3, 2022 - Serializable in java is a marker interface and has no fields or methods to implement. It’s like an Opt-In process through which we make our classes serializable. Serialization in java is implemented by ObjectInputStream and ObjectOutputStream, so all we need is a wrapper over them to either ...
🌐
TutorialsPoint
tutorialspoint.com › serializable-interface-in-java
Serializable Interface in Java
May 12, 2023 - The Serializable interface provides the facility to serialize an object. It does not define any methods and member variables. When a class implements serializable interface it simply indicates this class and its sub-classes can be serialized. The ser
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › io › Serializable.html
Serializable (Java Platform SE 7 )
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.
🌐
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 - Let’s understand what Serializable means, when it matters, and how it's different from the JSON serialization you see in everyday APIs. All we know is that Serializable is a marker interface—it has no methods, no fields, no obvious behavior.
🌐
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.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › io › Serializable.html
Serializable (Java SE 17 & JDK 17)
October 20, 2025 - 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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › serialization-and-deserialization-in-java
Serialization and Deserialization in Java - GeeksforGeeks
June 2, 2025 - Only the objects of those classes can be serialized which are implementing java.io.Serializable interface. Serializable is a marker interface (has no data member and method). It is used to "mark" java classes so that objects of these classes ...
🌐
Medium
medium.com › @AlexanderObregon › a-deep-dive-into-java-serialization-e514346ac2b2
Java Serialization Full Deep Dive | Medium
November 6, 2023 - This interface is a marker interface, meaning it does not contain any methods to implement; it merely signals to the Java Virtual Machine (JVM) that the object is eligible for serialization.
🌐
Jenkov
jenkov.com › tutorials › java-io › serializable.html
Java IO: Serializable
September 4, 2015 - Java object serialization (writing) is done with the ObjectOutputStream and deserialization (reading) is done with the ObjectInputStream. That Serializable is a marker interface means that it contains no methods. Therefore, a class implementing ...
🌐
GeeksforGeeks
geeksforgeeks.org › serialization-in-java
Serialization and Deserialization in Java with Example | GeeksforGeeks
January 4, 2025 - Only the objects of those classes can be serialized which are implementing java.io.Serializable interface. Serializable is a marker interface (has no data member and method). It is used to "mark" java classes so that objects of these classes ...
🌐
Tutorialspoint
tutorialspoint.com › java › java_serialization.htm
Java - Serialization
The class must implement the java.io.Serializable interface. All of the fields in the class must be serializable. If a field is not serializable, it must be marked transient.