# Serialization: exclude nulls with \`encodeToString\` method while \`encodeDefaults = true

**URL:** <https://discuss.kotlinlang.org/t/serialization-exclude-nulls-with-encodetostring-method-while-encodedefaults-true/22416>\
**Category:** Libraries\
**Created:** [July 14, 2021, 6:10pm UTC](https://discuss.kotlinlang.org/t/serialization-exclude-nulls-with-encodetostring-method-while-encodedefaults-true/22416 "2021-07-14T18:10:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Psijic](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/psijic/32/2227_2.png) [@Psijic](https://discuss.kotlinlang.org/u/Psijic)\
**Post date:** [July 14, 2021, 6:10pm UTC](https://discuss.kotlinlang.org/t/serialization-exclude-nulls-with-encodetostring-method-while-encodedefaults-true/22416/1 "2021-07-14T18:10:59Z")

</div>

How is it possible to exclude nulls with `encodeToString` method while `encodeDefaults = true` ? Looks like a [popular topic](https://github.com/Kotlin/kotlinx.serialization/issues/195).
