<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq" -->

---
title: Stop telling people to sanitize user input | daily.dev
description: A strong argument against the common advice to 'sanitize user input', explaining the important distinction between sanitization and validation. Sanitization...
canonical: https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Stop telling people to sanitize user input | daily.dev
og:description: A strong argument against the common advice to 'sanitize user input', explaining the important distinction between sanitization and validation. Sanitization...
og:url: https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq
og:image: https://api.daily.dev/og/posts/iGpjYFaWq.png
og:image:alt: Stop telling people to sanitize user input
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Stop telling people to sanitize user input

**[unixsheikh.com](https://daily.dev/sources/unixsheikh)** · 6 min read · 51 upvotes · 9 comments

## Summary

A strong argument against the common advice to 'sanitize user input', explaining the important distinction between sanitization and validation. Sanitization modifies data based on assumed intent, risking data loss and misinterpretation, while validation checks that input meets defined requirements without altering it. The correct approach is to validate input, reject non-conforming data, use prepared statements to prevent SQL injection, and encode/escape data at the point of use — not at the point of storage. Client-side validation is also insufficient for security since it can always be bypassed.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://unixdigest.com/articles/stop-telling-people-to-sanitize-user-input.html>

## Community discussion

Top comments from developers on daily.dev.

**@peternormann** · 7 upvotes

> I agree. I believe the main issue is that a lot of tutorials are oblivious to the importance of using prepared statements.
>
> Case in point, I recently saw a video posted on YouTube from a company that specialized in security.
>
> They went on and on about why it's important to sanitize and escape user input due to risk of SQL injection.
>
> It was agonizing to watch people giving advice appearing to be "authoritative" on a subject, only to provide information that is flawed, revealing they completely missed the mark. They never mentioned prepared statements.
>
> Always use prepared statements. Always....

**@markojr** · 4 upvotes

> _"After the data has been received you _**_MUST_**_ encode and escape the data when it is being used."_
>
> isn't it more efficient to encode and escape your data before you store it into the database?
>
> I mean that's essentially what sanitization is ...
>
> I don't see why you should Sanitize after reading the data from the DB. I think the Author and I have different understandings on what **"sanitizing" **is

**@hardik15** · 2 upvotes

> It's about which data you are collecting and how you want your UX to be.
>
>
> If you have textbox and you don't want special characters in that, while copying text from another place if it copies some special characters, user may be frustrated with the validation error constantly showing

**@killshot13** · 2 upvotes

> Dear readers! Don't misinterpret the clickbait title as **"Stop telling people to worry about user input completely."** Let me save you 5 minutes.
>
>
> The whole article is just the author bashing people for not understanding the semantic/technical difference between sanitizing and validating, and for using the terms interchangeably. While I agree with the author's point of view, given the provocative title, I found the delivery shallow and repetitive.

**@sqlmancer** · 1 upvotes

> I think your definition of "sanitizing" is not the same as what most people mean when they talk about sanitizing inputs.  Using your definition, you are correct.  However, people who don't use your definition, are also correct when they sanitize their inputs.

## Similar posts on daily.dev

- [Express Validator - Part 1: Why Your API Should Never Trust Client Input](https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd) · Medium · 1 upvotes · 0 comments
- [What Is a Vulnerability, Really? Source, Sink, and Taint](https://daily.dev/posts/what-is-a-vulnerability-really-source-sink-and-taint-csw3ozbnk) · Awesome Java Newsletter · 0 upvotes · 0 comments
- [Improper Input Handling Leading to Client Side Code Execution and Backend Information Disclosure](https://daily.dev/posts/improper-input-handling-leading-to-client-side-code-execution-and-backend-information-disclosure-sfyadtont) · InfoSec Write-ups · 1 upvotes · 0 comments
- [SQL Injection: Why It Persists and How to Prevent It](https://daily.dev/posts/sql-injection-why-it-persists-and-how-to-prevent-it-a5i6fyqpz) · Latest Hacking News · 0 upvotes · 0 comments

---

Tags: [#appsec](https://daily.dev/tags/appsec), [#sql](https://daily.dev/tags/sql), [#web-security](https://daily.dev/tags/web-security)

[View this post on daily.dev](https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Stop telling people to sanitize user input","url":"https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq"},"datePublished":"2026-03-07T03:57:50.187Z","dateModified":"2026-10-14T02:35:49.162Z","description":"A strong argument against the common advice to 'sanitize user input', explaining the important distinction between sanitization and validation. Sanitization...","image":"https://media.daily.dev/image/upload/s--HRgLpUt6--/f_auto/v1722860399/public/Placeholder%2003","thumbnailUrl":"https://media.daily.dev/image/upload/s--HRgLpUt6--/f_auto/v1722860399/public/Placeholder%2003","isAccessibleForFree":true,"articleSection":"unixsheikh.com","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"unixsheikh.com","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/e27e8f168b3f473894c93b9aba197adf","url":"https://daily.dev/sources/unixsheikh"},"commentCount":9,"discussionUrl":"https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":51},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":9}],"keywords":"appsec,sql,web-security","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"unixsheikh.com","item":"https://daily.dev/sources/unixsheikh"},{"@type":"ListItem","position":3,"name":"Stop telling people to sanitize user input"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq","comment":[{"@type":"Comment","text":"I agree. I believe the main issue is that a lot of tutorials are oblivious to the importance of using prepared statements.\nCase in point, I recently saw a video posted on YouTube from a company that specialized in security.\nThey went on and on about why it’s important to sanitize and escape user input due to risk of SQL injection.\nIt was agonizing to watch people giving advice appearing to be “authoritative” on a subject, only to provide information that is flawed, revealing they completely missed the mark. They never mentioned prepared statements.\nAlways use prepared statements. Always. Even if there is no user input, you know it might creep in there eventually, so just prepare the statements regardless.\nValidate input, use prepared statements, escape output, done.","datePublished":"2026-03-07T08:03:38.145Z","dateModified":"2026-03-07T08:04:21.697Z","url":"https://daily.dev/posts/iGpjYFaWq#c-TVwiD5D2r","author":{"@type":"Person","name":"Peter Normann","url":"https://daily.dev/peternormann","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7}},{"@type":"Comment","text":"“After the data has been received you MUST encode and escape the data when it is being used.”\nisn’t it more efficient to encode and escape your data before you store it into the database?\nI mean that’s essentially what sanitization is …\nI don’t see why you should Sanitize after reading the data from the DB. I think the Author and I have different understandings on what **“sanitizing” **is","datePublished":"2026-03-07T17:04:34.546Z","dateModified":"2026-03-07T17:04:58.372Z","url":"https://daily.dev/posts/iGpjYFaWq#c-kxAkaElgc","author":{"@type":"Person","name":"Marko Jozic-Reyes","url":"https://daily.dev/markojr","image":"https://media.daily.dev/image/upload/s--TvIfWcng--/f_auto/v1769558803/avatars/avatar_x9cfuU5ai02W3BPEbroGK?_a=BAMAMiiu0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}},{"@type":"Comment","text":"It’s about which data you are collecting and how you want your UX to be.\nIf you have textbox and you don’t want special characters in that, while copying text from another place if it copies some special characters, user may be frustrated with the validation error constantly showing","datePublished":"2026-03-08T11:13:58.943Z","url":"https://daily.dev/posts/iGpjYFaWq#c-vLFJ0ELlG","author":{"@type":"Person","name":"Hardik","url":"https://daily.dev/hardik15","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Dear readers! Don’t misinterpret the clickbait title as “Stop telling people to worry about user input completely.” Let me save you 5 minutes.\nThe whole article is just the author bashing people for not understanding the semantic/technical difference between sanitizing and validating, and for using the terms interchangeably. While I agree with the author’s point of view, given the provocative title, I found the delivery shallow and repetitive.","datePublished":"2026-03-25T13:10:10.091Z","url":"https://daily.dev/posts/iGpjYFaWq#c-8VABuzqU7","author":{"@type":"Person","name":"Michael Rehnert","url":"https://daily.dev/killshot13","image":"https://media.daily.dev/image/upload/f_auto/v1627784981/avatars/frrfkLRFu"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"I think your definition of “sanitizing” is not the same as what most people mean when they talk about sanitizing inputs.  Using your definition, you are correct.  However, people who don’t use your definition, are also correct when they sanitize their inputs.","datePublished":"2026-03-15T13:42:18.268Z","url":"https://daily.dev/posts/iGpjYFaWq#c-Rk16NFviR","author":{"@type":"Person","name":"David Cram","url":"https://daily.dev/sqlmancer","image":"https://lh3.googleusercontent.com/a/AGNmyxYA76uDRQagdzZtTrLKWf6AaIDhJCjl8DMKfyvN=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}]}
```

