When you get ready to craft your survey, you should be asking yourself why you are asking each question - including demographic questions. It's important for a variety of reasons to only ask questions that will inform your research. Consider if demographic questions will be important for understanding the rest of your data before asking them. It may be interesting to know the demographics behind your questions, but why is it interesting for your purposes?
If you decide that you do need to know demographic questions, make this abundantly clear in the survey. You can often include this information in the section on demographics as an introductory text. This will help your survey participants understand why you're asking and feel more comfortable about providing the information.
People grow tired of being asked to complete surveys as well as filling out surveys. Here are some tips to encourage participation.
Keep your survey as short as possible
This goes back to the question of "Why are you collecting this information?" Make sure each question you ask has a purpose for your research. Be very mindful of scope creep and try to keep focused on your research question.
Make sure you ask questions clearly
Use non-specialist language as much as possible to ensure your participants understand what the question is asking. Avoid questions that ask multiple things, such as "do you drink or smoke cigarettes?" Break this question up into two questions, "Do you drink alcohol?" and "Do you smoke cigarettes?" This will also help you when analyzing your data.
Allow participants to skip questions
You of course want your participants to complete all the questions, but be mindful of which questions you need them to answer to be useful to your research, and which questions are supporting information. If participants can't skip questions that they don't understand or don't find relevant, they're more likely to just quit the survey.
Use skip logic to avoid asking irrelevant questions
Skip logic is way to direct people through your survey based on their answers to certain questions. For example, if you ask if participants their highest level of education, those who answer high school or earlier can skip questions related to university or college attendance.