← Back to list

Serialization Vs Marshaling in Java

Difference b/w Serialization and Marshalling

Lavanyaravichandran · 2025-01-28 05:32 · 1 claps · 1.2 min read
#serialization #marshalling #java #jaxb #network
Open on Medium ↗
Wiki topics: 🔭 · Astronomy & Space

Serialization Vs Marshaling in Java

Difference b/w Serialization and Marshalling

Serialization and marshalling are both processes used to convert objects into a format that can be easily transmitted or stored. However both have some difference,

1. Serialization :

1.1 Definition : It is the process of converting an object into a byte stream, which can be then saved into a file , sent over network or stored in a database.

1.2 Usage : Commonly used to transfer files over a network in serialized format

1.3 Format : Stored in a byte stream (binary format), not human readable format.

1.4 Default Constructor : It is not mandatory to have default constructoe but having it in class can be helpful for deserialization.

1.5 Example : Java ObjectOutpurStream and ObjectInputStream are used for Serialization and Deserialization

1.6 For more detail about Serialization :

2. What is Marshalling ?

2.1 Definition : It is the process of converting an object into a format like XLM or JSON with codebase details.so that can be transported in network easily. It is a broader term of Serialization.

2.2 Usage : Commonly used in web services and API to convert objects to XML or JSON for communication between different systems.

2.3 Format : Stored in a text based human readable format like JSON and XML

2.4 Default Constructor : Class should have default constructor.

2.5 Example : JAXB is used for Marshal and Unmarshal.

2.6 For more detail about Serialization :

https://medium.com/@7lavanyaravichandran/jaxb-2b4f4fd32c4d

Is Serialization and Marshalling are same?

No, but both has one common thing which is transfer of data.

In Serialization only object is serialized, whereas in Marshalling the object is serialized and codebase is attached with that.

Serialization is part of marshalling.

Marshalling is Serialization + codebase.

Performance Comparison :

Serialization : Generally faster and more compact but can be CPU and memory-intensive.

Marshalling : More flexible and interoperable but can be slower and produce larger data Size.


메타데이터
post_id
80b069fe1ec5
slug
serialization-vs-marshaling-in-java-80b069fe1ec5
url
https://medium.com/@7lavanyaravichandran/serialization-vs-marshaling-in-java-80b069fe1ec5
canonical_url
https://medium.com/@7lavanyaravichandran/serialization-vs-marshaling-in-java-80b069fe1ec5
author_url
https://medium.com/@7lavanyaravichandran
status
ok
fetched_at
2026-07-21 04:28:33