The Adventure docs are currently a work in progress. Some areas may have limited coverage or may not be entirely up to date. Feel free to join our discord at https://discord.gg/MMfhJ8F if you have any questions.

Text Serializers

The lowest-level way to convert between Adventure’s data and other formats are serializers. Some serializers convert to standard formats, while others convert to Adventure’s own formats.


Components can be converted using any of these serializers:

// Creates a text component
final TextComponent textComponent = TextComponent.of("Hello ")
      decoration(TextDecoration.BOLD, true)

// Converts textComponent to the JSON form used for serialization by Minecraft.
String json = GsonComponentSerializer.gson().serialize(textComponent);

// Converts textComponent to a legacy string - "&6Hello &b&lworld&c!"
String legacy = LegacyComponentSerializer.legacyAmpersand().serialize(textComponent);

// Converts textComponent to a plain string - "Hello world!"
String plain = PlainComponentSerializer.INSTANCE.serialize(textComponent);

The same is of course also possible in reverse for deserialization.

// Converts JSON in the form used for serialization by Minecraft to a Component
Component component = GsonComponentSerializer.gson().deserialize(json);

// Converts a legacy string (using formatting codes) to a TextComponent
TextComponent component = LegacyComponentSerializer.legacyAmpersand().deserialize("&6Hello &b&lworld&c!");

// Converts a plain string to a TextComponent
TextComponent component = PlainComponentSerializer.INSTANCE.deserialize("Hello world!");