Difference between value_template: >- and value_template: >

Can someone tell me what the difference is between

value_template: >-


value_template: >

Why would I want to do one over the other or is there a best practice on which I should use?

The - is todo with stripping whitespace. 99.9% of the time in homeassistant it is an unnecessary addition (because we’re not usually formatting text for display, we’re creating a value for a key).


1 Like

That said, is it good practice to use >- instead of just > ? Is there a better/more safe route? I guess I need to pick one and just go with it so I do that everywhere and am trying to come to that conclusion - I just don’t know enough about which one is considered better and/or safer.

After reading that page, it seems like using >- is the better route to go but not sure.

Not really, you’re just putting an extra character in for no reason :man_shrugging:

1 Like

To make things even more difficult you could also use | :grin:

They all have different effects. You can read about them in the jinja2 documentation.
As long as you are not returning text it doesn’t really matter, as has been said.


I have templates that return text, I don’t use the whitespace control character, and the output doesn’t have superfluous whitespace.

The only place I see a difference is in the Template Editor.

1 Like

This mostly matters, when you return longer texts, in notifications for example, and want to controll the formatting like line breaks, etc.