German literature, especially written in the 18th and 19th century by bourgois writers, is certainly written in a language that has only minor differences to modern Hochdeutsch. If you look back to the 17th century, this might not always be the case. In the period around and after the Thirty Years War, the written German showed some appreciable differences, mostly in vocabulary, but also sometimes in grammar. These differences are not uniform, and can often be traced back to dialect roots.
Nonetheless, the difference between speaking in dialect and writing in Standard German, was something all writers were aware of. Let me give you an example from a writer who was not part of the well-educated higher class: Hans Jakob Christoffel von Grimmelshausen, author of the 1688 bestselling novel Der abenteuerliche Simplicissimus. He is from Frankonia (the Kinzig valley to be exact, although he identifies also with the Spessart hills to the south). When he uses words from his native region, he sometimes feels the need to explain:
Zwar ohngeschertzt/ mein Herkommen und Aufferziehung läst
sich noch wol mit eines Fürsten vergleichen/ wann
man nur den grossen Unterscheid nicht ansehen wolte/ was? Mein Knan (dann also nennet man die Vätter im Spessert) hatte einen eignen Pallast...
Shortly after, he describes a dialog with his father about the finer points of shepharding, where he freely interlaces descriptive text in Standard German with direct speech in Frankonian dialect:
Aber indessen wieder zu meiner Heerd zu kommen/
so wisset/ daß ich den Wolff eben so wenig kennet/
als meine eigene Unwissenheit selbsten; derowegen
war mein Knan mit seiner Instruction desto fleissiger:
Er sagte/ Bub biß fleissig/ loß di Schoff nit ze weit
vunananger laffen/ un spill wacker uff der Sackpfeiffa/ daß der Wolff nit kom/ und Schada dau/ dann
he yß a solcher feyerboinigter Schelm und Dieb/ der
Menscha und Vieha frisst/ un wan dau awer farlässj
bisst/ so will eich dir da Buckel arauma. Ich antwortet mit gleicher Holdseeligkeit: Knano/ sag
mir aa/ wey der Wolff seyhet? Eich huun
noch kan Wolff gesien: Ah dau grober Eselkopp/ replicirt er hinwieder/ dau bleiwest dein
Lewelang a Narr/ geith meich wunner/ was
auß dir wera wird/ bißt schun su a grusser
Dölpel/ un waist noch neit/ was der Wolff
für a feyerfeussiger Schelm iß. Er gab mir
noch mehr Unterweisungen/ und wurde zuletzt unwillig/ massen er mit einem Gebrümmel fort gieng/
weil er sich beduncken liesse/ mein grober Verstand
könte seine subtile Unterweisungen nicht fassen.
Da fienge ich an mit meiner Sackpfeiffen so gut
Geschirr zu machen/ daß man den Krotten im
Krautgarten damit hätte vergeben mögen/...
Note the interspersed latin words (Instruction, replicirt, subtile) and literary expressions never to be heard in spoken language (Holdseeligkeit, lovelyness). But then, in the next paragraph, he starts out with several dialect expressions without acknowledging them: gut Geschirr machen (gut aufspielen, strike up well), Krotten (Kröten, toads) and vergeben (vergiften, to poison).
All citations are from the first edition Nürnberg 1688, facsimile at Deutsches Textarchiv. Some typesetting features have been exchanged for more common latin letters for the sake of reproducing them in a readable way. The dialect translations are from the 1984 edition by Aufbau Verlag; there are more explanations in reference to the quoted text: feierboinigter: vierbeiniger, four-legged; arauma: vollhauen, bash up; geith meich wunner: nimmt mich wunder, it astonishes me.
The Aufbau editor, Günther Deicke, starts his remarks with the following note on edition history:
"Der abenteurliche Simplicissimus Teutsch" erschien zum ersten Male im Herbst 1688, mit der Jahreszahl 1669. Der große Erfolg dieses bei Wolff Eberhard Felßecker in Nürnberg verlegten Werkes veranlaßte den Frankfurter Verleger Georg Müller, das Werk sprachlich zu überarbeiten, mundartliche Formen Grimmelshausens durch hochsprachliche zu ersetzen und das Werk in dieser Form nachzudrucken. Felßecker rächte sich an dieser Geschäftsschädigung, indem er vermutlich Grimmelshausen veranlasste, für die nächste erweiterte Ausgabe diesen überarbeiteten Text zu verwenden. Er hoffte dadurch einen noch größeren Leserkreis zu erreichen.
(Translated with DeepL.com)
"Der abenteurliche Simplicissimus Teutsch" was first published in autumn 1688, with the date 1669. The great success of this work, published by Wolff Eberhard Felßecker in Nuremberg, prompted the Frankfurt publisher Georg Müller to revise the language of the work, to replace Grimmelshausen's dialectal forms with standard ones and to reprint the work in this form. Felßecker took revenge for this damage to his business by presumably getting Grimmelshausen to use this revised text for the next expanded edition. He thus hoped to reach an even wider readership.
He then goes on to reason why he preferred the first edition. But that is an attitude that only developed in the second half of the 20th century. Before that, revisions were common editing practices. They started with exchanging Fraktur typesetting with Latin, but also non-standard word forms, unusual grammar and "obsolete" spelling were "modernized". So even if the original work was written in a form that had more dependence on dialectal backgrounds, they would reach you in most cases in a form where everything "hard to understand" had long been expunged, or would be explained in footnotes (from a 1874 edition):