How do you use /title properly? [duplicate]

How do you use /title? I used it like this

/title @a title {text:"you're fighting the castle",bold:true,italic:true,color:red}" 

and it gave me this error

[10:51:17] Invalid json: malformed JSON at line 1 column 3

I'm trying to make something and I've been stuck for a while so if anyone knows please help me!!!


Solution 1:

Here is the command with proper JSON formatting:

/title @a title {"text":"you're fighting the castle","color":"red","bold":true,"italic":true}

You were missing quotation marks around text, color, red, bold, and italic. You also have a single quotation mark at the very end which shouldn't be there.

I recommend using a JSON generator. This makes it easy as you don't have to know JSON formatting.

One example which can do titles: https://www.minecraftjson.com/