Skip to content

Form data is returned in as strings, not in correct TS types #6600

Answered by krzysdz
IgorArnaut asked this question in Q&A
Discussion options

You must be logged in to vote

Unless you have special client-side JS code to change it, HTML <form>s can be sent as:

Neither of those encodings preserves information about data type (number, string, bool, Date), so effectively everything is a string. One exception is multipart/form-data, which sends a bit more information about files.

Checkboxes and radio buttons that are not checked are not sent. Checked ones are sent with value being their value attribute if it is specified or the string "on".

This has nothing to do with Express. It's just how HTML forms work.

You have a couple options to solve your problems:

  • validate and parse every…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bjohansebas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #6517 on June 28, 2025 01:22.