Skip to main content
Prashardan
Level 4
Jan 28, 2025 10:17 AM UTC
Solved

Handling \n Characters in AEM Content Fragments

Hi Team

When inputting a newline character (\n) in any text field of an AEM content fragment, the JSON output shows \\n instead of \n. This leads to inconsistencies, as the UI displays the newline correctly, but the JSON response doesn't reflect the intended formatting

How to address this any advise.

Thanks in advance.

PRATHYUSHA_VP
PRATHYUSHA_VPAccepted solution
Community Advisor
Jan 28, 2025 11:14 AM UTC

Hi @prashardan ,

 

Use multi-value rich text property for updating the special characters in the CF field. 

Just enter the content in new line in CF field. In the JSON it appends /n on it's own when rich text property used like below -

 

 

 

 

Hope this helps

 

Thanks

 

 

Prathyusha - AEM Developer

2 replies

PRATHYUSHA_VP
Community Advisor
PRATHYUSHA_VPCommunity AdvisorAccepted solution
Community Advisor
Jan 28, 2025 11:14 AM UTC

Hi @prashardan ,

 

Use multi-value rich text property for updating the special characters in the CF field. 

Just enter the content in new line in CF field. In the JSON it appends /n on it's own when rich text property used like below -

 

 

 

 

Hope this helps

 

Thanks

 

 

Translate
Prathyusha - AEM Developer
AmitVishwakarma
Community Advisor
Community Advisor
Feb 2, 2025 7:25 AM UTC

To handle newline characters (\n) properly in AEM Content Fragments, you can use a multi-value rich text property. When you enter content with line breaks in the Content Fragment field, AEM will automatically encode it with \n for line breaks.
Solution:

1. Use Multi-value Rich Text Property: This allows AEM to handle newline characters properly when the content is entered in the field.

2. Behavior: When using this property, you can enter the content with new lines, and AEM will ensure that \n appears in the JSON output instead of \\n.

 

Translate
Amit Vishwakarma - Adobe Commerce Champion 2025 | 17x Adobe certified | 6x Adobe SME