This snippet converts a NSAttributedString to HTML markup returned as NSString: + (NSString*) htmlForAttributedString:(NSAttributedString*) attrString { NSArray * exclude = [NSArray arrayWithObjects:@"doctype", @"html", @"head", @"body", @"xml", nil ]; NSDictionary * htmlAtt = [NSDictionary dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType, NSDocumentTypeDocumentAttribute, exclude, NSExcludedElementsDocumentAttribute, nil ]; NSError * error; NSData * ...